2

Original Question

After installing auto-py-to-exe (https://pypi.org/project/auto-py-to-exe/) and trouble shooting my installation problems (How to convert .py to .exe - pip install auto-py-to-exe works but auto-py-to-exe does not) I am having problems running the newly generated 'exe' file.

I get the error message -

ModuleNotFoundError: No module named 'pandas'

I thought I had already installed 'pandas'

Microsoft Windows [Version 10.0.17134.165]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\Users\HP>auto-py-to-exe
^C
C:\Users\HP>pip3 install pandas

Requirement already satisfied: pandas in c:\users\hp\anaconda3\lib\site-packages (0.24.2)
Requirement already satisfied: numpy>=1.12.0 in c:\users\hp\anaconda3\lib\site-packages (from pandas) (1.17.2)
Requirement already satisfied: pytz>=2011k in c:\users\hp\anaconda3\lib\site-packages (from pandas) (2019.1)

Requirement already satisfied: python-dateutil>=2.5.0 in c:\users\hp\anaconda3\lib\site-packages (from pandas) (2.8.0)
Requirement already satisfied: six>=1.5 in c:\users\hp\anaconda3\lib\site-packages (from python-dateutil>=2.5.0->pandas) (1.12.0)

C:\Users\HP>pip install pandas
Requirement already satisfied: pandas in c:\users\hp\anaconda3\lib\site-packages (0.24.2)

Requirement already satisfied: numpy>=1.12.0 in c:\users\hp\anaconda3\lib\site-packages (from pandas) (1.17.2)
Requirement already satisfied: pytz>=2011k in c:\users\hp\anaconda3\lib\site-packages (from pandas) (2019.1)
Requirement already satisfied: python-dateutil>=2.5.0 in c:\users\hp\anaconda3\lib\site-packages (from pandas) (2.8.0)
Requirement already satisfied: six>=1.5 in c:\users\hp\anaconda3\lib\site-packages (from python-dateutil>=2.5.0->pandas) (1.12.0)

C:\Users\HP>pip --version
pip 19.2.3 from c:\users\hp\anaconda3\lib\site-packages\pip (python 3.7)

Do I have a compatibility issue?

INSTALLED VERSIONS
------------------
commit: None
python: 3.7.3.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 142 Stepping 10, GenuineIntel
byteorder: little
LC_ALL: None
LANG: en
LOCALE: None.None

pandas: 0.24.2
pytest: 5.0.1
pip: 19.2.3
setuptools: 41.0.1
Cython: 0.29.12
numpy: 1.17.2
scipy: 1.2.1
pyarrow: None
xarray: None
IPython: 7.6.1
sphinx: 2.1.2
patsy: 0.5.1
dateutil: 2.8.0
pytz: 2019.1
blosc: None
bottleneck: 1.2.1
tables: 3.5.2
numexpr: 2.6.9
feather: None
matplotlib: 3.1.0
openpyxl: 2.6.2
xlrd: 1.2.0
xlwt: 1.3.0
xlsxwriter: 1.1.8
lxml.etree: 4.3.4
bs4: 4.7.1
html5lib: 1.0.1
sqlalchemy: 1.3.5
pymysql: None
psycopg2: None
jinja2: 2.10.1
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None

This was the output from the software -

Running auto-py-to-exe v2.6.5
Building in the current instances temporary directory at C:\Users\HP\AppData\Local\Temp\tmpcgwenk45
To get a new temporary directory, restart this application
Recursion Limit is set to 5000
Executing: pyinstaller -y  "C:/Users/HP/Documents/Python Scripts/ExcelReader.py"
107309 INFO: PyInstaller: 3.5
107309 INFO: Python: 3.7.3
107310 INFO: Platform: Windows-10-10.0.17134-SP0
107311 INFO: wrote C:\Users\HP\AppData\Local\Temp\tmpcgwenk45\ExcelReader.spec
107583 INFO: UPX is not available.
107654 INFO: Extending PYTHONPATH with paths
['C:\\Users\\HP\\Documents\\Python Scripts',
 'C:\\Users\\HP\\AppData\\Local\\Temp\\tmpcgwenk45']
107655 INFO: checking Analysis
107655 INFO: Building Analysis because Analysis-00.toc is non existent
107655 INFO: Initializing module dependency graph...
107804 INFO: Initializing module graph hooks...
108085 INFO: Analyzing base_library.zip ...
116454 INFO: running Analysis Analysis-00.toc
116554 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\users\hp\appdata\local\programs\python\python37-32\python.exe
122179 INFO: Caching module hooks...
122519 INFO: Analyzing C:\Users\HP\Documents\Python Scripts\ExcelReader.py
122534 INFO: Loading module hooks...
122535 INFO: Loading module hook "hook-encodings.py"...
122667 INFO: Loading module hook "hook-pydoc.py"...
122709 INFO: Loading module hook "hook-xml.py"...
123270 INFO: Looking for ctypes DLLs
123270 INFO: Analyzing run-time hooks ...
123291 INFO: Looking for dynamic libraries
130447 INFO: Looking for eggs
130447 INFO: Using Python library c:\users\hp\appdata\local\programs\python\python37-32\python37.dll
130447 INFO: Found binding redirects: 
[]
130461 INFO: Warnings written to C:\Users\HP\AppData\Local\Temp\tmpcgwenk45\build\ExcelReader\warn-ExcelReader.txt
130527 INFO: Graph cross-reference written to C:\Users\HP\AppData\Local\Temp\tmpcgwenk45\build\ExcelReader\xref-ExcelReader.html
130602 INFO: checking PYZ
130602 INFO: Building PYZ because PYZ-00.toc is non existent
130618 INFO: Building PYZ (ZlibArchive) C:\Users\HP\AppData\Local\Temp\tmpcgwenk45\build\ExcelReader\PYZ-00.pyz
131177 INFO: Building PYZ (ZlibArchive) C:\Users\HP\AppData\Local\Temp\tmpcgwenk45\build\ExcelReader\PYZ-00.pyz completed successfully.
131207 INFO: checking PKG
131208 INFO: Building PKG because PKG-00.toc is non existent
131208 INFO: Building PKG (CArchive) PKG-00.pkg
131458 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
131468 INFO: Bootloader c:\users\hp\appdata\local\programs\python\python37-32\lib\site-packages\PyInstaller\bootloader\Windows-32bit\run.exe
131469 INFO: checking EXE
131470 INFO: Building EXE because EXE-00.toc is non existent
131470 INFO: Building EXE from EXE-00.toc
131485 INFO: Appending archive to EXE C:\Users\HP\AppData\Local\Temp\tmpcgwenk45\build\ExcelReader\ExcelReader.exe
131537 INFO: Building EXE from EXE-00.toc completed successfully.
131540 INFO: checking COLLECT
131541 INFO: Building COLLECT because COLLECT-00.toc is non existent
131553 INFO: Building COLLECT COLLECT-00.toc
134365 INFO: Building COLLECT COLLECT-00.toc completed successfully.
Moving project to: C:\Users\HP\output
Complete.

Update 1

I solved the problem by typing 'pandas' into '--hidden-import'. Click the link for a screenshot. Screenshot of Advanced Options

Ross Symonds
  • 690
  • 1
  • 8
  • 29

2 Answers2

4

The following information relating to the --hidden-import flag may be important to the build process and may resolve your issue. This is from the blog post that appears in the link in your question:

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 (e.g. '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.

Dodge
  • 3,219
  • 3
  • 19
  • 38
0

If you have additional files involved in a program you need to move the .exe file that's created to the folder where the main.py normally is. Than it will use all the files and paths that's involved in a process

Sergey
  • 1
  • 1