0

I am running a python2 package that uses wx on a MacBook. I'm running python 2.7.10. When I run the package:

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

so I try to install wx following advice from Python ImportError: No module named wx

I try to install via pip as also suggested on https://wxpython.org/pages/downloads/index.html:

pip install -U wxPython

&

sudo pip install wxPython

&

sudo -H pip install wxPython

but all of these say that it's already installed:

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)

and yet I get the original error back when I try to run run_pasta_gui.py

I was able to get this done on my Ubuntu VM by sudo apt-get install python-wxtools but this obviously isn't available on a Mac.

Following Unable to import a module that is definitely installed I've tried sudo chmod -R ugo+rX /usr/local/lib/python2.7/site-packages/ but I'm still unable to access the wx package.

How can I get wx working for my python2 installation?

con
  • 5,767
  • 8
  • 33
  • 62
  • 1
    Are you sure you're running the script with the correct Python installation? Can you specify the installation explicitly? Are you not using virtual environments? – AMC Mar 30 '20 at 20:38
  • @AMC python is 2.7.10 How can I tell that pip is directly working with that version? there shouldn't be any other python versions locally. I'm not using virtual environments – con Mar 30 '20 at 20:42
  • _there shouldn't be any other python versions locally._ That can't be the issue, then. Weird. – AMC Mar 30 '20 at 20:52

1 Answers1

0

I ran the install in venv, and I was able to import and list the module

(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']

shaolin
  • 73
  • 1
  • 7