takluyver / pynsist

Build Windows installers for Python applications
https://pynsist.readthedocs.io/
Other
896 stars 119 forks source link

ImportError: namespace packages do not have loaders when building installer #130

Closed luisdelatorre012 closed 6 years ago

luisdelatorre012 commented 6 years ago

I'm getting an ImportError when creating an installer in Windows. I've successfully built installers on this machine with the same environment.

I'm running 64-bit python 3.5.1 on 64-bit windows.

The output of running pynsist installer.cfg is below.

Unpacking Python...
Copying packages into build directory...
Using cached wheel: PyQt5-5.9-5.9.1-cp35.cp36.cp37-none-win_amd64.whl
Using cached wheel: sip-4.19.3-cp35-none-win_amd64.whl
Using cached wheel: matplotlib-2.1.0-cp35-cp35m-win_amd64.whl
Using cached wheel: image-1.5.15-py2.py3-none-any.whl
Traceback (most recent call last):
  File "C:\Users\chq-luisd\AppData\Local\Continuum\Anaconda3\envs\py35\Lib\runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\chq-luisd\AppData\Local\Continuum\Anaconda3\envs\py35\Lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\chq-luisd\cog_solver_py35\Scripts\pynsist.exe\__main__.py", line 9, in <module>
  File "c:\users\chq-luisd\cog_solver_py35\lib\site-packages\nsist\__init__.py", line 540, in main
    InstallerBuilder(**args).run(makensis=(not options.no_makensis))
  File "c:\users\chq-luisd\cog_solver_py35\lib\site-packages\nsist\__init__.py", line 495, in run
    self.prepare_packages()
  File "c:\users\chq-luisd\cog_solver_py35\lib\site-packages\nsist\__init__.py", line 381, in prepare_packages
    py_version=self.py_version, exclude=self.exclude)
  File "c:\users\chq-luisd\cog_solver_py35\lib\site-packages\nsist\copymodules.py", line 224, in copy_modules
    mc.copy(modname, target, exclude)
  File "c:\users\chq-luisd\cog_solver_py35\lib\site-packages\nsist\copymodules.py", line 113, in copy
    loader = importlib.find_loader(modname, self.path)
  File "c:\users\chq-luisd\cog_solver_py35\lib\importlib\__init__.py", line 104, in find_loader
    name=name)
ImportError: namespace packages do not have loaders
takluyver commented 6 years ago

What is in the packages= section of your config file? If possible, it's best to list any required packages in pypi_wheels - this is a more robust mechanism than copying packages from your system. If the necessary package doesn't provide wheels, unfortunately I can well believe that copying a namespace package is not working.

luisdelatorre012 commented 6 years ago

I'll list as many packages under pypi_wheels as possible. Some packages I'm using I installed from wheels at http://www.lfd.uci.edu/~gohlke/pythonlibs/ and not pypi. Other than extracting wheels into the pynsist_pkgs folder, is it possible to include wheels from other sources (local wheels?)?

takluyver commented 6 years ago

At present, no, but it's something I plan to add - see #107.

luisdelatorre012 commented 6 years ago

I'm trying to add packages under pypi_wheels and getting a NoWheel error for some of them. Here is the error with python-pptx==0.6.6 under pypi_wheels:

(cog_solver_py35) C:\Users\chq-luisd\PycharmProjects\cog_solver>pynsist installer.cfg
Unpacking Python...
Copying packages into build directory...
Traceback (most recent call last):
  File "C:\Users\chq-luisd\AppData\Local\Continuum\Anaconda3\envs\py35\Lib\runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\chq-luisd\AppData\Local\Continuum\Anaconda3\envs\py35\Lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\chq-luisd\cog_solver_py35\Scripts\pynsist.exe\__main__.py", line 9, in <module>
  File "c:\users\chq-luisd\cog_solver_py35\lib\site-packages\nsist\__init__.py", line 540, in main
    InstallerBuilder(**args).run(makensis=(not options.no_makensis))
  File "c:\users\chq-luisd\cog_solver_py35\lib\site-packages\nsist\__init__.py", line 495, in run
    self.prepare_packages()
  File "c:\users\chq-luisd\cog_solver_py35\lib\site-packages\nsist\__init__.py", line 377, in prepare_packages
    py_version=self.py_version, bitness=self.py_bitness)
  File "c:\users\chq-luisd\cog_solver_py35\lib\site-packages\nsist\pypi.py", line 206, in fetch_pypi_wheels
    whl_file = wd.fetch()
  File "c:\users\chq-luisd\cog_solver_py35\lib\site-packages\nsist\pypi.py", line 109, in fetch
    raise NoWheelError('No compatible wheels found for {0.name} {0.version}'.format(self))
nsist.pypi.NoWheelError: No compatible wheels found for python-pptx 0.6.6

I created a fresh virtualenv and pip install python-pptx==0.6.6 does in fact install, but I'm not sure if it's installing from a wheel or source.

The output from pip install python-pptx==0.6.6 is

(testenv) (C:\Users\chq-luisd\AppData\Local\Continuum\Anaconda3) C:\Users\chq-lu
isd\testenv\testenv\Scripts>pip install --trusted-host pypi.python.org python-pp
tx==0.6.6
Collecting python-pptx==0.6.6
Collecting Pillow>=2.6.1 (from python-pptx==0.6.6)
  Downloading Pillow-4.3.0-cp35-cp35m-win_amd64.whl (1.5MB)
    100% |################################| 1.5MB 1.1MB/s
Collecting lxml>=3.1.0 (from python-pptx==0.6.6)
  Downloading lxml-4.1.0-cp35-cp35m-win_amd64.whl (3.5MB)
    100% |################################| 3.5MB 5.4MB/s
Collecting XlsxWriter>=0.5.7 (from python-pptx==0.6.6)
  Downloading XlsxWriter-1.0.2-py2.py3-none-any.whl (139kB)
    100% |################################| 143kB 20.5MB/s
Collecting olefile (from Pillow>=2.6.1->python-pptx==0.6.6)
Installing collected packages: olefile, Pillow, lxml, XlsxWriter, python-pptx
Successfully installed Pillow-4.3.0 XlsxWriter-1.0.2 lxml-4.1.0 olefile-0.44 pyt
hon-pptx-0.6.6
takluyver commented 6 years ago

No, python-pptx doesn't have a wheel, unfortunately. Though I don't currently see where it needs a namespace package either. :-/

luisdelatorre012 commented 6 years ago

Whenever possible, I put packages under pypi_wheels. For packages without wheels, I extracted local wheels into pynsist_pkgs - the only thing under [Include] is now the pypi_wheels section.

I'm still getting the same namespace package error. How can I figure out which package(s) are causing this error?

takluyver commented 6 years ago

I've just released Pynsist 2 - it should give you a more helpful error message in that case, and it also provides an option to use wheels from a specified local directory (docs).

luisdelatorre012 commented 6 years ago

Version 2 gave me the error message I was hoping for, and my installer is now built. Thanks for all the help! Closing this.

takluyver commented 6 years ago

Great :-)