2

I am currently dabbling in Python. I have now created a mini project for testing. For this I have installed PySide6 and built a none window:

from PySide6.QtWidgets import QApplication, QMainWindow
from widgets.main import Ui_frmMain

class FrmMain(QMainWindow, Ui_frmMain):
    def __init__(self):
        super().__init__()
        self.setupUi(self)

app = QApplication()
frm_main = FrmMain()
frm_main.show()
app.exec()

Now I wanted to create a macOS app with py2app

python3 setup.py py2app -A

After running it I wanted to test the file and get the following error message

Fatal Python error: init_import_site: 
Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
File "/Users/xxx/Python3/python-projekte/beginner/dist/main.app/Contents/Resources/site.py",     line 182, in <module>
import sitecustomize  # noqa: F401
File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/sitecustomize.py", line 38, in <module>
site.PREFIXES[:] = [new_prefix if x == sys.prefix else x for x in site.PREFIXES]
AttributeError: partially initialized module 'site' has no attribute 'PREFIXES' (most likely due to a circular import)

Do you have any idea?

When searching for the cause in the forum I had leider keine success

Vitalizzare
  • 4,496
  • 7
  • 13
  • 32
  • 1
    I had the exact same problem with a small demo PySide6 app and py2app. It turned out something was wrong with my virtualenv. Have you tried to delete and recreate it? – Vince Aug 25 '23 at 15:49

1 Answers1

0

i see in documentation that setup tools support for py2app is optional. Did you install py2app as follow?

pip install -U 'py2app[setuptools]'

I see that you use one of newer python version (3.10).In documentation, there is statement that setuptools interface is deprecated (link)[https://py2app.readthedocs.io/en/latest/command-line.html]. Please try to use like command-line tool

python3 -m py2app
Farfax
  • 3
  • 1