簡體   English   中英

Python:在 Mac 上安裝 wx 失敗

[英]Python: installation of wx fails on Mac

我正在運行一個在 MacBook 上使用wx的 python2 包。 我正在運行 python 2.7.10。 當我運行包時:

con@company_computer:~/dir/pasta$ python run_pasta_gui.py 
Traceback (most recent call last):
  File "run_pasta_gui.py", line 27, in <module>
    import wx
ImportError: No module named wx

所以我嘗試按照Python ImportError 的建議安裝 wx : No module named wx

我嘗試按照https://wxpython.org/pages/downloads/index.html 上的建議通過 pip 安裝:

pip install -U wxPython

&

sudo pip install wxPython

&

sudo -H pip install wxPython

但所有這些都說它已經安裝:

Requirement already satisfied: wxPython in /usr/local/lib/python2.7/site-packages (4.0.7.post2)
Requirement already satisfied: pillow in /usr/local/lib/python2.7/site-packages (from wxPython) (6.2.2)
Requirement already satisfied: six in /usr/local/lib/python2.7/site-packages (from wxPython) (1.11.0)
Requirement already satisfied: numpy<1.17; python_version <= "2.7" in /usr/local/lib/python2.7/site-packages (from wxPython) (1.14.2)

但是當我嘗試運行run_pasta_gui.py時,我又得到了原來的錯誤

我能夠通過sudo apt-get install python-wxtools在我的 Ubuntu VM 上完成這項工作,但這顯然在 Mac 上不可用。

無法導入絕對安裝的模塊之后,我嘗試了sudo chmod -R ugo+rX /usr/local/lib/python2.7/site-packages/但我仍然無法訪問wx包。

如何讓wx為我的 python2 安裝工作?

我在 venv 中運行安裝,並且能夠導入並列出模塊

(venv) air:~ yo$ pip install wxPython Collecting wxPython Downloading https://files.pythonhosted.org/packages/17/b0/3a39e3fbea922e2f1bf2a48d5ed14d7eb1173ec8dbd3a1187f105ae06355/wxPython-4.0.7.post2-cp27-cp27m-macosx_10_9_x86_64.whl (16.9MB) |████████████████████████████████| 16.9MB 3.4MB/s Collecting pillow Downloading https://files.pythonhosted.org/packages/d1/6a/41719faa7421602a85941867059f53787ac40c85c8fe9e6bb48809e3246e/Pillow-6.2.2-cp27-cp27m-macosx_10_6_intel.whl (3.9MB) |████████████████████████████████| 3.9MB 2.7MB/s Collecting numpy<1.17; python_version <= "2.7" Downloading https://files.pythonhosted.org/packages/09/96/84cf406fe7d589f3dba9fc0f737e65985a3526c6d8c783f02d4b5a10825d/numpy-1.16.6-cp27-cp27m-macosx_10_9_x86_64.whl (13.9MB) |████████████████████████████████| 13.9MB 301kB/s Requirement already satisfied: six in ./work/virtualenvs/venv/lib/python2.7/site-packages (from wxPython) (1.13.0) Installing collected packages: pillow, numpy, wxPython Successfully installed numpy-1.16.6 pillow-6.2.2 wxPython-4.0.7.post2

Python 2.7.16 (default, Feb 29 2020, 01:55:37) [GCC 4.2.1 Compatible Apple LLVM 11.0.3 (clang-1103.0.29.20) (-macos10.15-objc- on darwin Type "help", "copyright", "credits" or "license" for more information. import wx print(dir()) ['__builtins__', '__doc__', '__name__', '__package__', 'wx']

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM