简体   繁体   中英

Python to executable - unable to import modules

Running Python 3.5 on Win10 x64. Have tried py2exe, PyInstaller and cxfreeze. All of them run and generate an .exe. But none of the .exes run with all of them immediately closing after an error. All of them have warning logs with a huge list of required modules that couldn't be imported properly.

PyInstaller:

missing module named time.time - imported by time, http.cookies
...
missing module named urllib.proxy_bypass - imported by urllib, requests.compat 
...

cxfreeze:

Missing modules:

    ? Cookie imported from requests.compat
    ? Image imported from openpyxl.drawing.image
    ? OpenSSL.SSL imported from requests.packages.urllib3.contrib.pyopenssl
    ? StringIO imported from requests.compat, requests.packages.urllib3.packages.six
    ...

PyInstaller also throws dependancy errors such as "api-ms-win-crt-runtime-l1-1-0.dll" missing. I have Visual C++ 2005-2015 all installed with Visual Studio Community 15 installed too.

PyInstaller 3.0  Python 3.5 on Win10 x64 with Visual Studio Community 15 
works for me. I run pyinstaller --onefile file_script.py
    in windows path i have the folowing
    C:\Python35;
    C:\Python35\Scripts;
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin;

Turns out that this is an issue with openpyxl which was a module being imported.

https://bitbucket.org/openpyxl/openpyxl/issues/498/moving-constants-to-a-configuration-file https://bitbucket.org/openpyxl/openpyxl/pull-requests/67/include-constantsjson-as-part-of-the/diff https://bitbucket.org/openpyxl/openpyxl/pull-requests/83/use-__about__py-instead-of-constantsjson/diff

Downloading a copy of the repository, using the changes made in the last URL and then installing openpyxl from that (using `pip install -e (openpyxldirectory) allows a working .exe to be generated

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