Noah Jb
Noah Jb

Reputation: 87

Compiling a python script with Pyinstaller via terminal

I am using macOS, and Anaconda 3 in order to manage my libraries and write the script.

I want to create an executable for my script.

I am using Pyinstaller in Terminal to run the command:

pyinstaller --onefile /Directory/file.py

However, Terminal returns this error:

File "/anaconda3/lib/python3.6/site-packages/PyInstaller/hooks/hook-sysconfig.py", line 42, in <module> hiddenimports = [sysconfig._get_sysconfigdata_name()] TypeError: _get_sysconfigdata_name() missing 1 required positional argument: 'check_exists'

How can I solve this problem; thank you for your assistance.

Upvotes: 5

Views: 1898

Answers (2)

ethanjyx
ethanjyx

Reputation: 2069

conda update conda did not work for me, so I will just post my solution here.

First, go to python interactive shell, do

$ python
>> import sysconfig
>> print(sysconfig.__file__)

This should give you where the file locates for sysconfig. Then what you need to go to that file and edit the source code, for me it was /opt/conda/envs/test/lib/python3.6/sysconfig.py, then find the function and change function signature for _get_sysconfigdata_name, what I did was make check_exists default to True.

Upvotes: 4

apogalacticon
apogalacticon

Reputation: 789

This is a known issue in older versions of Anaconda. You can try to update Anaconda (in the conda terminal):

conda update conda

You can also try to remove the sysconfig._get_sysconfigdata_name() from the hiddenimports list in your .spec file and instead add import sysconfig in your .py file.

The following issue documentation on the pyinstaller github page may be of further help: https://github.com/pyinstaller/pyinstaller/issues/3192

Upvotes: 3

Related Questions