1

I've set up a virtual environment on MacOS BigSur 11.6 using python 3.9.7 version. Environment name is "ambiente" and this is how the terminal looks like :

(ambiente) mac.fede@Ahoga PageDownloader % 

I'm in PageDownloader directory. Inside this folder there is my python project. I can run the program using : python3 PageDownloader.py and all works fine.

I tried to install and run it using PyInstaller and the UNIX executable works fine.

Then using Platypus I bottled it to an application, when the icon is double clicked a shell script runs and launches the UNIX executable file obtained before.

When I double click the application this is the output :

​initializing script //this launches PageDownloader Executable file

Python path configuration:
  PYTHONHOME = '/Users/mac.fede/Documents/GitHub/PageDownloader/PageDownloader.app/Contents/Resources'
  PYTHONPATH = (not set)
  program name = '/Users/mac.fede/Documents/GitHub/PageDownloader/PageDownloader.app/Contents/Resources/PageDownloader'
  isolated = 0
  environment = 0
  user site = 0
  import site = 0
  sys._base_executable = '/Users/mac.fede/Documents/GitHub/PageDownloader/PageDownloader.app/Contents/Resources/PageDownloader'
  sys.base_prefix = ''
  sys.base_exec_prefix = ''
  sys.platlibdir = 'lib'
  sys.executable = '/Users/mac.fede/Documents/GitHub/PageDownloader/PageDownloader.app/Contents/Resources/PageDownloader'
  sys.prefix = ''
  sys.exec_prefix = ''
  sys.path = [
    '/Users/mac.fede/Documents/GitHub/PageDownloader/PageDownloader.app/Contents/Resources/base_library.zip',
    '/Users/mac.fede/Documents/GitHub/PageDownloader/PageDownloader.app/Contents/Resources/lib-dynload',
    '/Users/mac.fede/Documents/GitHub/PageDownloader/PageDownloader.app/Contents/Resources',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
Current thread 0x000000010c0cfe00 (most recent call first):
<no Python frame>

Other posts on StackOverflow like this : Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding, when trying to start uwsgi

Suggests to remove the PYTHONHOME environment variable but I don't know how to do it. I can see that it's set and shouldn't. I did some researches on the internet but I didn't understand how to do this on Mac. I already tried :

unset PYTHONPATH
unset PYTHONHOME

Before launching the executable file but same error. Now, I don't know if this is the right way to create an exportable application from python program on MacOS, I'm trying to figure it out so all this solution is "home made". If you have any suggestion I would be very happy to hear it.

With "exportable" I mean an application that I can share with my friends or other people and runnable with a double click.

Finley Adams
  • 773
  • 1
  • 8
  • 20

0 Answers0