Search code examples
pythonvirtualenvpyinstaller

Trying to make .exe with pyinstaller, but pyinstaller can't find google-cloud-bigquery


I've solved this problem already.

It's because of virtualenv. You need to install pyinstaller in virtual environment you are using.


I've tried some solutions, but still can't solve this problem,

  1. adding hook path to hookspath=[]: 'C:\python\lib\site-packages_pyinstaller_hooks_contrib\hooks\stdhooks\hook-google.cloud.bigquery.py'

  2. using --collect-submodules google or --collect-submodules google.cloud

  3. adding hidden import to hiddenimports=[]

It could go wrong even in the most simple program with single line like from google.cloud import bigquery in test.py

Some error message are as below:

pkg_resources.DistributionNotFound: The 'google-cloud-bigquery' distribution was not found and is required by the application

or while running the main.exe the terminal says

File "journey_renew_upgrade\main.py", line 3, in <module>
ImportError: cannot import name 'bigquery' from 'google.cloud' (unknown location)

Also, I am wondering if it is possible to use -D flag to make a directory, and copy google.cloud.bigquery into this directory?


Solution

  • I've solved this problem already.

    It's because of virtualenv. You need to install pyinstaller in virtual environment you are using.