简体   繁体   中英

auto-py-to-exe : module requests not found

I got a python script that I want to convert into.exe, I use auto-py-to-exe to do this. My file is inside a folder, which also has text files and pictures which are required for the program to work.

I fill the fields normally, run it and then try the.exe: module requests not found . Requests is the first import I do in my python script.

I saw this on Nitratine ( https://nitratine.net/blog/post/issues-when-using-auto-py-to-exe/ ):

"ModuleNotFoundError: No module named x / ImportError: No module named x

This means a particular module ('x' in this case) was not added to the package. I have seen this occur with packages in the pandas library and win32api; as long as you can identify the package (eg 'x'), then it is very easy to fix.

To fix this in the UI, open the advanced tab and find the --hidden-import input. Simply paste the module name into this input and then repackage. If the original error is still appearing, you have done this incorrectly.

For example, if you are missing pandas._libs.tslib, add 'pandas._libs.tslib' into the input by --hidden-import. Additionally, you can add more than one module, for example, pandas._libs.tslib, win32api. (See the question mark by the input for more information)."

Then, I found this question: Cannot run Python file as.exe file, getting error 'ModuleNotFoundError: No module named 'pandas' '

It seems he faced the same error with pandas (quote from Nitratine: "I have seen this occur with packages in the pandas library and win32api") and followed Nitratine's solution, and it worked.

He shared a screenshot: https://i.stack.imgur.com/WMpws.png

So I did the exact same, I put "requests" inside the field, and then... "Failed to execute the script".

Mmmmmh.

How can I resolve this error please?

EDIT: here are the logs of the command:

Running auto-py-to-exe v2.7.5
Building directory: C:\Users\ELVE~1\AppData\Local\Temp\tmpgj8a1e2a
Provided command: pyinstaller --noconfirm --onedir --windowed --add-data "C:/Hack/ProxyCrawler;ProxyCrawler/" --hidden-import "requests"  "C:/Hack/ProxyCrawler/Script.py"
Recursion Limit is set to 5000
Executing: pyinstaller --noconfirm --onedir --windowed --add-data C:/Hack/ProxyCrawler;ProxyCrawler/ --hidden-import requests C:/Hack/ProxyCrawler/Script.py --distpath C:\Users\ELVE~1\AppData\Local\Temp\tmpgj8a1e2a\application --workpath C:\Users\ELVE~1\AppData\Local\Temp\tmpgj8a1e2a\build --specpath C:\Users\ELVE~1\AppData\Local\Temp\tmpgj8a1e2a

49308 INFO: PyInstaller: 3.6
49321 INFO: Python: 3.7.7
49334 INFO: Platform: Windows-10-10.0.17763-SP0
49343 INFO: wrote C:\Users\ELVE~1\AppData\Local\Temp\tmpgj8a1e2a\Script.spec
49358 INFO: UPX is not available.
49391 INFO: Extending PYTHONPATH with paths
['C:\\Hack\\ProxyCrawler',
 'C:\\Users\\ELVE~1\\AppData\\Local\\Temp\\tmpgj8a1e2a']
49401 INFO: checking Analysis
49406 INFO: Building Analysis because Analysis-00.toc is non existent
49418 INFO: Initializing module dependency graph...
49521 INFO: Caching module graph hooks...
49568 INFO: Analyzing base_library.zip ...
56240 INFO: Processing pre-find module path hook   distutils
56269 INFO: distutils: retargeting to non-venv dir 'c:\\panda3d-1.10.6-x64\\python\\lib'
61992 INFO: Caching module dependency graph...
62249 INFO: running Analysis Analysis-00.toc
62301 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\panda3d-1.10.6-x64\python\python.exe
62521 INFO: Analyzing C:\Hack\ProxyCrawler\Script.py
63303 INFO: Processing pre-safe import module hook   urllib3.packages.six.moves
69165 INFO: Processing module hooks...
69170 INFO: Loading module hook "hook-certifi.py"...
69191 INFO: Loading module hook "hook-distutils.py"...
69209 INFO: Loading module hook "hook-encodings.py"...
69456 INFO: Loading module hook "hook-pydoc.py"...
69466 INFO: Loading module hook "hook-sysconfig.py"...
69479 INFO: Loading module hook "hook-xml.py"...
69807 INFO: Loading module hook "hook-_tkinter.py"...
70226 INFO: checking Tree
70233 INFO: Building Tree because Tree-00.toc is non existent
70246 INFO: Building Tree Tree-00.toc
70500 INFO: checking Tree
70507 INFO: Building Tree because Tree-01.toc is non existent
70521 INFO: Building Tree Tree-01.toc
70603 INFO: Looking for ctypes DLLs
70610 INFO: Analyzing run-time hooks ...
70630 INFO: Including run-time hook 'pyi_rth__tkinter.py'
70659 INFO: Including run-time hook 'pyi_rth_certifi.py'
70695 INFO: Looking for dynamic libraries
71326 INFO: Looking for eggs
71334 INFO: Using Python library c:\panda3d-1.10.6-x64\python\python37.dll
71347 INFO: Found binding redirects: 
[]
71362 INFO: Warnings written to C:\Users\ELVE~1\AppData\Local\Temp\tmpgj8a1e2a\build\Script\warn-Script.txt
71481 INFO: Graph cross-reference written to C:\Users\ELVE~1\AppData\Local\Temp\tmpgj8a1e2a\build\Script\xref-Script.html
71552 INFO: Appending 'datas' from .spec
71570 INFO: checking PYZ
71580 INFO: Building PYZ because PYZ-00.toc is non existent
71586 INFO: Building PYZ (ZlibArchive) C:\Users\ELVE~1\AppData\Local\Temp\tmpgj8a1e2a\build\Script\PYZ-00.pyz
72799 INFO: Building PYZ (ZlibArchive) C:\Users\ELVE~1\AppData\Local\Temp\tmpgj8a1e2a\build\Script\PYZ-00.pyz completed successfully.
72843 INFO: checking PKG
72851 INFO: Building PKG because PKG-00.toc is non existent
72861 INFO: Building PKG (CArchive) PKG-00.pkg
72927 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
72938 INFO: Bootloader c:\panda3d-1.10.6-x64\python\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe
72953 INFO: checking EXE
72963 INFO: Building EXE because EXE-00.toc is non existent
72993 INFO: Building EXE from EXE-00.toc
73024 INFO: Appending archive to EXE C:\Users\ELVE~1\AppData\Local\Temp\tmpgj8a1e2a\build\Script\Script.exe
73219 INFO: Building EXE from EXE-00.toc completed successfully.
73239 INFO: checking COLLECT
73247 INFO: Building COLLECT because COLLECT-00.toc is non existent
73265 INFO: Building COLLECT COLLECT-00.toc
87856 INFO: Building COLLECT COLLECT-00.toc completed successfully.

Moving project to: C:\Users\Elève\output
Complete.

(I'm french so it's normal if you don't understand names like "Elève" (student) or so)

EDIT N°2: Eric Mathieu tried to help me through comments, and he mentionned "build" and "dist" folders that should appear. I don't get any of them, and while following a tutorial to try get more help I found this:

https://datatofish.com/wp-content/uploads/2019/03/004_pyinstaller.png

So he got a "pycache" folder (I can't put the two _ because else the word pycache becomes bold ^^'), a "dist" and a "build" one also. I have "pycache", but none of "dist" or "build"... Maybe this can help?

The tutorial I talk about is here: https://datatofish.com/executable-pyinstaller/

I fixed that by installing the module using pip:

pip install requests

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