我的问题如下。我试图打包一个python脚本,写一个在CX_freeze的其他计算机上运行。经过一番摆弄后,我把脚本打包了但是当我去运行代码时我得到了:
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]
现在这很令人困惑,因为如果我从IDLE运行脚本,一切都很完美。我开始尝试从终端运行原始脚本(.py而不是.app)而只是python IP*
但是我继续得到ModuleNotFoundError
我升级的Pandas w / Pip3并且一切都是最新的,仍然没有运气。然而,当在IDLE中运行时,该程序运行良好。我继续搜索我的问题,发现了link。我按照建议并添加到我的程序顶部
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
程序仍然像以前一样完全从IDLE运行,现在当我在终端运行它时出现了这个错误
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']
现在我不知道该怎么做。我相信如果我让程序从终端正确运行,那么它有希望与CX_Freeze结合并运行。感谢。
tl; dr: .py脚本完全从IDLE运行,但从终端运行时会返回ImportError: Missing required dependencies ['numpy']