pyinstaller executable can't find package info
See original GitHub issueThe pyinstaller complains the error with the following line:
from gcloud.pubsub.client import Client
The module is installed correctly in /usr/local/lib/python2.7/dist-packages. I run setup.py (build/ install) in addition pip install --upgrade cloud too.
Traceback (most recent call last):
  File "<string>", line 267, in <module>
  File "/usr/local/lib/python2.7/dist-packages/PyInstaller-2.1.1dev_-py2.7.egg/PyInstaller/loader/pyi_importers.py", line 271, in load_module
    exec(bytecode, module.__dict__)
  File "/home/mtwu/gce/cloudn/cloudx-local/gce/gce_pubsub.py", line 6, in <module>
  File "/usr/local/lib/python2.7/dist-packages/PyInstaller-2.1.1dev_-py2.7.egg/PyInstaller/loader/pyi_importers.py", line 271, in load_module
    exec(bytecode, module.__dict__)
  File "/home/mtwu/gce/cloudn/install/build/cloudx_cli/out00-PYZ.pyz/gcloud", line 19, in <module>
  File "/home/mtwu/gce/cloudn/install/build/cloudx_cli/out00-PYZ.pyz/pkg_resources", line 551, in get_distribution
The following import will cause the following pyinstaller error.
from gcloud.pubsub.client import Client
  File "/home/mtwu/gce/cloudn/install/build/cloudx_cli/out00-PYZ.pyz/pkg_resources", line 431, in get_provider
  File "/home/mtwu/gce/cloudn/install/build/cloudx_cli/out00-PYZ.pyz/pkg_resources", line 952, in require
  File "/home/mtwu/gce/cloudn/install/build/cloudx_cli/out00-PYZ.pyz/pkg_resources", line 839, in resolve
pkg_resources.DistributionNotFound: The 'gcloud' distribution was not found and is required by the application
mtwu@ubuntu:/usr/local/lib/python2.7/dist-packages$ ls -l gcloud 
total 360
drwxr-sr-x 2 root staff  4096 Oct 16 09:13 bigquery
drwxr-sr-x 3 root staff  4096 Oct 16 09:13 bigtable
-rw-r--r-- 1 root staff  7564 Oct 16 09:13 client.py
-rw-r--r-- 1 root staff  8038 Oct 16 09:13 client.pyc
-rw-r--r-- 1 root staff 12949 Oct 16 09:13 connection.py
-rw-r--r-- 1 root staff 12304 Oct 16 09:13 connection.pyc
-rw-r--r-- 1 root staff 14075 Oct 16 09:13 credentials.py
-rw-r--r-- 1 root staff 13661 Oct 16 09:13 credentials.pyc
drwxr-sr-x 3 root staff  4096 Oct 16 09:13 datastore
-rw-r--r-- 1 root staff  4036 Oct 16 09:13 demo.py
-rw-r--r-- 1 root staff  4010 Oct 16 09:13 demo.pyc
drwxr-sr-x 2 root staff  4096 Oct 16 09:13 dns
-rw-r--r-- 1 root staff  1418 Oct 16 09:13 environment_vars.py
-rw-r--r-- 1 root staff   647 Oct 16 09:13 environment_vars.pyc
-rw-r--r-- 1 root staff  5819 Oct 16 09:13 exceptions.py
-rw-r--r-- 1 root staff  9026 Oct 16 09:13 exceptions.pyc
-rw-r--r-- 1 root staff  8048 Oct 16 09:13 _helpers.py
-rw-r--r-- 1 root staff 10032 Oct 16 09:13 _helpers.pyc
-rw-r--r-- 1 root staff   736 Oct 16 09:13 __init__.py
-rw-r--r-- 1 root staff   333 Oct 16 09:13 __init__.pyc
-rw-r--r-- 1 root staff  4957 Oct 16 09:13 iterator.py
-rw-r--r-- 1 root staff  5210 Oct 16 09:13 iterator.pyc
drwxr-sr-x 2 root staff  4096 Oct 16 09:13 pubsub
drwxr-sr-x 2 root staff  4096 Oct 16 09:13 resource_manager
drwxr-sr-x 2 root staff  4096 Oct 16 09:13 search
drwxr-sr-x 3 root staff  4096 Oct 16 09:13 storage
-rw-r--r-- 1 root staff  7021 Oct 16 09:13 test_client.py
-rw-r--r-- 1 root staff  9101 Oct 16 09:13 test_client.pyc
-rw-r--r-- 1 root staff 13090 Oct 16 09:13 test_connection.py
-rw-r--r-- 1 root staff 15451 Oct 16 09:13 test_connection.pyc
-rw-r--r-- 1 root staff 22622 Oct 16 09:13 test_credentials.py
-rw-r--r-- 1 root staff 28116 Oct 16 09:13 test_credentials.pyc
-rw-r--r-- 1 root staff  2844 Oct 16 09:13 test_exceptions.py
-rw-r--r-- 1 root staff  3664 Oct 16 09:13 test_exceptions.pyc
-rw-r--r-- 1 root staff 12177 Oct 16 09:13 test__helpers.py
-rw-r--r-- 1 root staff 19874 Oct 16 09:13 test__helpers.pyc
-rw-r--r-- 1 root staff  1143 Oct 16 09:13 _testing.py
-rw-r--r-- 1 root staff  1212 Oct 16 09:13 _testing.pyc
-rw-r--r-- 1 root staff  6781 Oct 16 09:13 test_iterator.py
-rw-r--r-- 1 root staff  8076 Oct 16 09:13 test_iterator.pyc
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:31 (9 by maintainers)
 Top Results From Across the Web
Top Results From Across the Web
(Pyinstaller) 'tclError: can't find package tkdnd' How can I fix ...
Show activity on this post. I'm trying to package my project into an executable file using pyinstaller. main.py, my program, should run when...
Read more >When Things Go Wrong — PyInstaller 5.7.0 documentation
In this case, the analysis can't tell if name is supposed to refer to a submodule or package. The “module not found” messages...
Read more >Pyinstaller: Module not found when running .exe when ...
The program tries to write a Pandas dataframe. This works find in PyCharm, but when I produce a Windows exe using PyInstaller it...
Read more >Using PyInstaller to Easily Distribute Python Applications
For more detailed information on the reader project, check out the the tutorial on Publishing a Package on PyPI. The first step to...
Read more >Easy Steps to Create an Executable in Python Using PyInstaller
The executable needs all the imports required for the Python script to work. Pyinstaller, at times, fails to identify dynamic imports or second ......
Read more > Top Related Medium Post
Top Related Medium Post
No results found
 Top Related StackOverflow Question
Top Related StackOverflow Question
No results found
 Troubleshoot Live Code
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free Top Related Reddit Thread
Top Related Reddit Thread
No results found
 Top Related Hackernoon Post
Top Related Hackernoon Post
No results found
 Top Related Tweet
Top Related Tweet
No results found
 Top Related Dev.to Post
Top Related Dev.to Post
No results found
 Top Related Hashnode Post
Top Related Hashnode Post
No results found

You will need to create a pyinstaller hook for packages that depend on setuptools’ get_distribution() to obtain metadata information about the package.
Create a hook file in some hooks directory. The file name should be
hook-<modulename>.pyfor pyinstaller to find it properly (i.e.hook-gcloud.py).The content will be:
The hooks directory should be set in the Analysis phase of your pyinstaller .spec file:
I haven’t tested the above, but this is what worked for me for another python package which is doing something similar (APScheduler).
If and when you get this working, consider contributing the hook back to pyinstaller project.
In the root folder of bogus.py two directories (build, dist) are created after executing
execute the binary by
and the said error should pop up.
I updated to google-cloud as instructed, the problem persists:
As @mtwu-aviatrix commented on Oct 29, 2015, the native interpreter has no problem with this import. The problem arises when it has been bundled by Pyinstaller (ver. 3.2).