OS:Windows 7 的Python:3.7 wxpython:4.0.3
这是我的代码: 如果我尝试导入wxpython,则会收到错误消息:请参见下文。
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import wx
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import wx
File "C:\Python37\lib\site-packages\wx\__init__.py", line 17, in <module>
from wx.core import *
File "C:\Python37\lib\site-packages\wx\core.py", line 12, in <module>
from ._core import *
ImportError: DLL load failed: The specified module could not be found.
导入sys后,出现另一个错误。
>>> import sys
>>> import wx
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import wx
File "C:\Python37\lib\site-packages\wx\__init__.py", line 12, in <module>
__version__ = wx.__version__.VERSION_STRING
AttributeError: module 'wx' has no attribute '__version__'
搜索没有太大帮助
我确实有网站包的正确路径
>>> sys.path
['', 'C:\\Python37\\Lib\\idlelib', 'C:\\Python37\\python37.zip', 'C:\\Python37\\DLLs', 'C:\\Python37\\lib', 'C:\\Python37', 'C:\\Python37\\lib\\site-packages']
>>>
但是,'C:\ Python37 \ lib \ site-packages'在lib中有小l。如果转到该文件夹,则lib的首字母拼写为大写L'Lib'。
wxpython是通过pip安装的
C:\Python37>pip3 install wxpython
Collecting wxpython
Downloading https://files.pythonhosted.org/packages/f7/62/bbe01210d84188c666a0
64c87362be9d6a015870f65615f2a9450e7b95b1/wxPython-4.0.3-cp37-cp37m-win32.whl (13
.8MB)
100% |¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶| 13.8MB 2.9MB/s
Requirement already satisfied: six in c:\python37\lib\site-packages (from wxpyth
on) (1.11.0)
Collecting PyPubSub (from wxpython)
Downloading https://files.pythonhosted.org/packages/ab/9e/3b50915d3346971aaa49
074425788598ee4907e67c097e013f1a862bd45c/Pypubsub-4.0.0-py3-none-any.whl (63kB)
100% |¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶| 71kB 10.2MB/s
Installing collected packages: PyPubSub, wxpython
Successfully installed PyPubSub-4.0.0 wxpython-4.0.3