对于Python 3.6,我已经将包“wxPython-Phoenix”安装到Conda环境中。 API表示它是使用“wx”导入的。但这不起作用:
runfile('/Users/bill/AnacondaProjects/ExcelMigration/DataMigrate.py', wdir='/Users/bill/AnacondaProjects/ExcelMigration')
<class 'ImportError'>
Traceback (most recent call last):
File "<ipython-input-9-aa949bc00bad>", line 1, in <module>
runfile('/Users/bill/AnacondaProjects/ExcelMigration/DataMigrate.py', wdir='/Users/bill/AnacondaProjects/ExcelMigration')
File "/anaconda3/envs/py36/lib/python3.6/site-packages/spyder/utils/site/sitecustomize.py", line 705, in runfile
execfile(filename, namespace)
File "/anaconda3/envs/py36/lib/python3.6/site-packages/spyder/utils/site/sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "/Users/bill/AnacondaProjects/ExcelMigration/DataMigrate.py", line 7, in <module>
import dfgui
File "/Users/bill/AnacondaProjects/ExcelMigration/dfgui.py", line 15, in <module>
import wx
ModuleNotFoundError: No module named 'wx'
实际的包名是wxPython-Phoenix,但名称空间是wx。
我也尝试使用“__”导入而不是“ - ”; “ - ”会引发语法错误。 “_”抛出“没有名为'wxPython_Phoenix'的模块。
答案 0 :(得分:0)
已回答 - 由于某种原因通过conda安装时wx的路径需要更具体的参考。我在sys.path中添加了wx.py的直接路径,导入能够找到库...