10

I am trying to build an .exe file from .py file using pysinstaller and Python 3.7.2.

It worked with Python 3.6; then I re-installed the last version of Python (3.7.2) and tried to generate an exe file, but pyinstaller barfs.

Below is the error report I get.

(venv) C:\Users\user\Desktop\untitled1>pyinstaller test.py

53 INFO: PyInstaller: 3.4
53 INFO: Python: 3.7.2
54 INFO: Platform: Windows-10-10.0.17134-SP0
58 INFO: wrote C:\Users\user\Desktop\untitled1\test.spec
60 INFO: UPX is not available.
61 INFO: Extending PYTHONPATH with paths
['C:\\Users\\user\\Desktop\\untitled1', 'C:\\Users\\user\\Desktop\\untitled1']
61 INFO: checking Analysis
187 INFO: checking PYZ
236 INFO: checking PKG
237 INFO: Building PKG because PKG-00.toc is non existent
238 INFO: Building PKG (CArchive) PKG-00.pkg

Traceback (most recent call last):
  File "C:\Users\user\Desktop\untitled1\venv\Scripts\pyinstaller-script.py", line 11, in  <module>
    load_entry_point('PyInstaller==3.4', 'console_scripts', 'pyinstaller')()
  File "C:\Users\user\Desktop\untitled1\venv\lib\site-packages\PyInstaller\__main__.py", line 111, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "C:\Users\user\Desktop\untitled1\venv\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "C:\Users\user\Desktop\untitled1\venv\lib\site- packages\PyInstaller\building\build_main.py", line 838, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))   
  File "C:\Users\user\Desktop\untitled1\venv\lib\site- packages\PyInstaller\building\build_main.py", line 784, in build
    exec(text, spec_namespace)
  File "<string>", line 29, in <module>   
  File "C:\Users\user\Desktop\untitled1\venv\lib\site-packages\PyInstaller\building\api.py", line 424, in __init__
    strip_binaries=self.strip, upx_binaries=self.upx,   
  File "C:\Users\user\Desktop\untitled1\venv\lib\site-packages\PyInstaller\building\api.py", line 196, in __init__
    self.__postinit__()
  File "C:\Users\user\Desktop\untitled1\venv\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
    self.assemble()   
  File "C:\Users\user\Desktop\untitled1\venv\lib\site-packages\PyInstaller\building\api.py", line 273, in assemble
    pylib_name = os.path.basename(bindepend.get_python_library_path())   
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\ntpath.py", line 214, in basename
    return split(p)[1]
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\ntpath.py", line 183, in split
    p = os.fspath(p) TypeError: expected str, bytes or os.PathLike object, not NoneType

What could be the problem?

1
  • I am having the same error. did you find any answer to this error? Feb 11, 2019 at 10:34

5 Answers 5

18

I found the following solution: replace bindepend.py from <myProject_path>\venv\Lib\site-packages\PyInstaller\depend with the file provided by Loran425 on github here

3
  • I did this and the build was also successful. But the application just closes on opening when opened from dist folder. When opened from inside build folder, it shows 'my_path'/python37.dll Module not Found error Any solution?
    – Kunj Mehta
    Mar 3, 2019 at 12:27
  • Worked for me, thank you. Would be more sustainable to have a new version of this file committed for PyInstaller project
    – DFE
    Mar 11, 2019 at 9:01
  • It has since been committed. It's not in a released PyInstaller but it's definitely in master today! May 30, 2019 at 17:47
2

As I have read from many forums here and here and discussions regarding this issue caused by Pyinstaller. If you are using Pycharm or any virtual environment. Unfortunatelly Pycharm creates its local vertual environment in venvpath once you indicate the interpreter. So, you should set the external tool (pyinstaller) to the real path of your python 3.7 .exe as the picture shows here. enter image description here

For Linux users, follow my other answer here.

2
  • Working directory is the directory where your project is stored, right?
    – Kunj Mehta
    Mar 3, 2019 at 12:30
  • 1
    @KunjMehta correct, it is also the directory where all of the imported libraries of your project are stored. Mar 3, 2019 at 18:59
2

In my case the problem occurs when I'm using the standard library's venv, but not when I'm using virtualenv. (However I had to use virtualenv==16.1.0 because of another bug.)

0
1

The bug was resolved in version 3.6 of PyInstaller. Just update and will work fine.

1
  • I had to remove uuid to upgrade past 3.5. uuid is now built-in but some packages will install it as a req because of python 2 compatibility.
    – VoteCoffee
    Apr 14, 2021 at 19:49
0

It may be from an ill-formed spec file, something as simple (yet difficult to find) as a commented or missing argument.

When I comment out name in exe,

exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          [],
          # name='my_app',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          upx_exclude=[],
          runtime_tmpdir=None,
          console=True,
          icon='resources/icons/icon.ico',
          version='resources/version/version.py')

I get the following traceback:

146666 INFO: Building PYZ (ZlibArchive) c:\projects\my-env\app\qc\tools\my_app\build\my_app_old\PYZ-00.pyz completed successfully.
Traceback (most recent call last):
  File "C:\Users\lorem\Anaconda3\envs\my-env\Scripts\pyinstaller-script.py", line 10, in <module>
    sys.exit(run())
  File "C:\Users\lorem\Anaconda3\envs\my-env\lib\site-packages\PyInstaller\__main__.py", line 114, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "C:\Users\lorem\Anaconda3\envs\my-env\lib\site-packages\PyInstaller\__main__.py", line 65, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "C:\Users\lorem\Anaconda3\envs\my-env\lib\site-packages\PyInstaller\building\build_main.py", line 720, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "C:\Users\lorem\Anaconda3\envs\my-env\lib\site-packages\PyInstaller\building\build_main.py", line 667, in build
    exec(code, spec_namespace)
  File "my_app_old.spec", line 49, in <module>
    version='resources/version/version.py')
  File "C:\Users\lorem\Anaconda3\envs\my-env\lib\site-packages\PyInstaller\building\api.py", line 382, in __init__
    self.name = os.path.join(CONF['distpath'], os.path.basename(self.name))
  File "C:\Users\lorem\Anaconda3\envs\my-env\lib\ntpath.py", line 214, in basename
    return split(p)[1]
  File "C:\Users\lorem\Anaconda3\envs\my-env\lib\ntpath.py", line 183, in split
    p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType

The application builds when name is included.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.