0

My problem is as follows. I'm trying to package a python script a wrote to run on other computers with CX_freeze. After some fiddling I got the script packaged but when I went to run the code I got:

Miless-foobar-Pro:~ milesconn$ /Users/milesconn/\~/Documents/   IPgeolookupforXLSX ; exit;
Traceback (most recent call last):
 File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-    packages/cx_Freeze/initscripts/__startup__.py", line 14, in run
        module.run()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site- packages/cx_Freeze/initscripts/Console.py", line 26, in run
        exec(code, m.__dict__)
File "/Users/milesconn/Desktop/IPgeolookupforXLSX.py", line 1, in <module>
        import sys 
ModuleNotFoundError: No module named 'pandas'
logout

[Process completed]

Now this was quite confusing because if I ran the script from IDLE everything worked perfectly. I started trying to run the original script (the .py not the .app) from terminal with simply python IP* but I continued to get the ModuleNotFoundError I upgraded Pandas w/ Pip3 and everything is up to date, still no luck. The program however worked perfectly when run in IDLE. I went on searching for my problem and found this link. I followed the advice and added to the top of my program

import sys 
sys.path.insert(1,'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages')
import pandas as pd
import numpy as np

Still the program ran from IDLE perfectly like before and now when I ran it in Terminal got this error

Traceback (most recent call last):
  File "IPgeolookupforXLSX.py", line 4, in <module>
    import pandas as pd
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/__init__.py", line 19, in <module>
    "Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']

Now I don't know what to do from here. I believe if I get the program to run from terminal correctly then it'll hopefully couple with CX_Freeze and run. Thanks.


tl;dr: .py script runs from IDLE perfectly but when run from terminal it returns a ImportError: Missing required dependencies ['numpy']

MilesConn
  • 301
  • 2
  • 13
  • What do you get when you do `import sys` and `print(sys.path)` in IDLE? Also, where are you launching your IDLE from? It's very likely that `python` in your path and the Python version used by IDLE are two different ones, where the latter has all the requirement modules installed. Either way, for Python app distribution this is the preferred method: https://www.digitalocean.com/community/tutorials/how-to-package-and-distribute-python-applications – zwer May 29 '17 at 18:48
  • Idle is being launched from `Macintosh HD/Applications/Python 3.6/IDLE` and sys.path returns `['/Users/milesconn/Desktop', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages', '/Users/milesconn/Documents', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python36.zip', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages']` I just installed Python from the website and did default install. – MilesConn May 29 '17 at 19:39

0 Answers0