简体   繁体   中英

Hidden import in PyInstaller not working?

I am trying to create an executable using PyInstaller. Important files for my problem are: main.py and dbinterface.py which are both located at the root level.

In dbinterface.py I am doing: import mysql.connector which would need to be added as an hidden-import to PyInstaller as I assume.

I tried this by adding --hidden-import pyinstaller mysql.connector and also by changing the spec-file which I am honestly not sure about whether I did this correctly.

PyInstaller show in the command line following line in it's output: 4448 ERROR: Hidden import 'mysql.connector' not found

The problem was that I had to install mysql-connector-python globally in Python. It's not working if you have them only instaled in your virtual environment.

You most probably need to also install your PyInstaller into the virtual environment and run PyInstaller from the virtual environment, not the one that is installed globally

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM