0

I have written some code which uses pandas. It is working fine when i execute it from the command prompt. But when I make it as a .exe file and try to run it from command prompt, it getting this error as below:

Traceback (most recent call last):
  File "Result_generator.py", line 2, in <module>
  File "c:\users\akhil\appdata\local\temp\pip-build-rccgn1\pyinstaller\PyInstaller\loader\pyimod03_importers.py", line 396, in load_module
  File "result_test.py", line 3, in <module>
  File "c:\users\akhil\appdata\local\temp\pip-build-rccgn1\pyinstaller\PyInstaller\loader\pyimod03_importers.py", line 396, in load_module
  File "site-packages\pandas\__init__.py", line 35, in <module>
ImportError: C extension: No module named tslib not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace --force' to build the C extensions first.
[12340] Failed to execute script Result_generator

I have installed tslib package also. But of no use. What is the wrong i am doing? Please help me with this. Thanks in Advance.

Doubt: In the error statement, it is saying to run "python setup.py..." command. But I didn't find any setup.py file in pandas directory. What is the solution for that?

Akhil Reddy
  • 371
  • 1
  • 6
  • 26
  • What's your Python version? and Pyinstaller, pandas ... – DDGG Mar 13 '18 at 02:53
  • Python 3.6.4 and pyinstaller 3.3.1 pandas 0.22 – Akhil Reddy Mar 13 '18 at 03:53
  • You can follow [this answer](https://stackoverflow.com/a/47501512/1730599), I have tested it! – DDGG Mar 13 '18 at 04:34
  • How to reinstally manually? I am not able to find setup.py file in PyInstaller folder – Akhil Reddy Mar 13 '18 at 04:47
  • You don't need to reinstall anything, just write a script named hook-pandas.py and put it into Python36-32\Lib\site-packages\PyInstaller\hooks. Then delete the `build` directory and run `pyinstaller -F your-script.py` – DDGG Mar 13 '18 at 04:51
  • Only one line in the file hook-pandas.py: `hiddenimports = ['pandas._libs.tslibs.timedeltas']` – DDGG Mar 13 '18 at 04:53
  • I added that ,then also i am getting this. "ImportError: C extension: No module named timedeltas not built" – Akhil Reddy Mar 13 '18 at 04:57
  • Be sure you deleted the `build` folder before you retry to run the pyinstaller. And it's better to delete both the `build` and the `dist` folders, to avoid exe update failed. – DDGG Mar 13 '18 at 05:37

0 Answers0