Home > OS >  Can't install python packages on my ubuntu virtual machine
Can't install python packages on my ubuntu virtual machine

Time:11-28

This is the full script:

(venv) ubuntu@ubuntu:~$ pip install wxPython
Collecting wxPython
  Using cached wxPython-4.2.0.tar.gz (71.0 MB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [12 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-jlwwpkvj/wxpython_66c7996a596740a4b92c4f3a3724336d/setup.py", line 27, in <module>
          from buildtools.config import Config, msg, opj, runcmd, canGetSOName, getSOName
        File "/tmp/pip-install-jlwwpkvj/wxpython_66c7996a596740a4b92c4f3a3724336d/buildtools/config.py", line 30, in <module>
          from attrdict import AttrDict
        File "/home/ubuntu/PycharmProjects/pythonProject/venv/lib/python3.10/site-packages/attrdict/__init__.py", line 5, in <module>
          from attrdict.mapping import AttrMap
        File "/home/ubuntu/PycharmProjects/pythonProject/venv/lib/python3.10/site-packages/attrdict/mapping.py", line 4, in <module>
          from collections import Mapping
      ImportError: cannot import name 'Mapping' from 'collections' (/usr/lib/python3.10/collections/__init__.py)
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
(venv) ubuntu@ubuntu:~$ 

I think cause of the problem is virtuel machine. I can download packages on my host OS. I am using UTM for ubuntu.

I try updating pip and setuptolls. I reinstalled differently ubuntu for multiple times. I am searcing forums for weeks and still nothing.

CodePudding user response:

You need to use an older version of Python (I am guessing 3.9). The best option is probably to set it up in virtualenv like this:

sudo apt update
sudo apt install python3.9
sudo apt-get install python3.9-dev python3.9-venv
python3.9 -m venv myenv
source venv/bin/activate
pip install wxPython

CodePudding user response:

Try to download the wheel (*.whl) file for that package and then:

pip install <wheel file path>
  • Related