Can't install python packages on my ubuntu virtual machine - python

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.

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

Try to download the wheel (*.whl) file for that package and then:
pip install <wheel file path>

Related

ImportError: cannot import name 'build_py_2to3' from 'distutils.command.build_py'

I tried to install bipwallet through pip but it says there is no 'build_py_2to3' in distutils
Defaulting to user installation because normal site-packages is not writeable
Collecting bipwallet
...
Collecting protobuf==3.0.0a3
Using cached protobuf-3.0.0a3.tar.gz (88 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [6 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-q8v8yny3/protobuf_3f1a8b67130540ab9c93af7fe765918c/setup.py", line 29, in <module>
from distutils.command.build_py import build_py_2to3 as _build_py
ImportError: cannot import name 'build_py_2to3' from 'distutils.command.build_py' (/home/orkhan/.local/lib/python3.11/site-packages/setuptools/_distutils/command/build_py.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.
I tried to search in Google but it did not help. I also tried
pip install --upgrade distutils
thinking maybe it's just older version.
P.S. my python version 3.11
It seems as though bipwallet or one of its dependencies (protobuf-3.0.0a3?) wants to use whatever version of setuptools is available rather than pinning a specific version. setuptools v58.0.0 has a breaking change, first included in Python 3.10, where build_py_2to3 was removed.
You have a couple options:
Find the offending library and edit its setup.py to indicate that it should use setuptools<=57.5.0 and retry.
Downgrade your Python installation to 3.9 to get a local version of setuptools prior to the breaking change.
Here are a couple other related posts/links to the issue you're seeing:
https://github.com/mhammond/pywin32/issues/1813
https://bytemeta.vip/repo/StanfordVL/iGibson/issues/227
https://github.com/mobinmbn/bipwallet_fix

Secrets pip not downloading MacOS

the secrets library is not downloading when I try to install the pip. My python is updated to 3.11.0. Wondering if that may be the issue?
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [13 lines of output]
Traceback (most recent call last):
File "/private/var/folders/bb/30cx945s3g9ftgw4q18zyw900000gn/T/pip-install-ll7ks8fq/secrets_1a6d2e6558c34836a716331c20614163/setup.py", line 10, in <module>
import OpenSSL
ModuleNotFoundError: No module named 'OpenSSL'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/private/var/folders/bb/30cx945s3g9ftgw4q18zyw900000gn/T/pip-install-ll7ks8fq/secrets_1a6d2e6558c34836a716331c20614163/setup.py", line 12, in <module>
raise ImportError('Installing this module requires OpenSSL python bindings')
ImportError: Installing this module requires OpenSSL python bindings
[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.
The last note leads me to believe that it is to do with the library itself.
A the error mentions: ImportError: Installing this module requires OpenSSL python bindings, you are probably missing OpenSSL bindings. They are part of the cryptography package.
Install them with pip install cryptography and try again.
EDIT: Python 3.11 is like a few days old. If it does not work you can also try to downscale to 3.10 or 3.9 as the packages is probably not supported yet in 3.11.

No module named 'distutils.command.bdist_msi'

In Pycharm (Windows 11) I set up a basic project consisting of one line:
import pycurl
The environment is Virtualenv, the base intepreter path is C:\Users\strat\AppData\Local\Programs\Python311\python.exe
Of course, since the module is not installed, I get:
Traceback (most recent call last):
File "C:\Users\strat\PycharmProjects\pythonProject3\main.py", line 6, in <module>
import pycurl
ModuleNotFoundError: No module named 'pycurl'
Process finished with exit code 1
So I try to install it, the way I generally do in Linux:
pip install pycurl
but I get:
Collecting pycurl
Using cached pycurl-7.45.1.tar.gz (233 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [9 lines of output]
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "C:\Users\strat\AppData\Local\Temp\pip-install-7dqnopvz\pycurl_f564efcc68fa4b198200e92ae58e8c8b\setup.py", line 954, in <module>
setup_args['cmdclass'] = {'bdist_msi': get_bdist_msi_version_hack()}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\strat\AppData\Local\Temp\pip-install-7dqnopvz\pycurl_f564efcc68fa4b198200e92ae58e8c8b\setup.py", line 594, in get_bdist_msi_version_hack
from distutils.command.bdist_msi import bdist_msi
ModuleNotFoundError: No module named 'distutils.command.bdist_msi'
[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.
What's the origin of this error? As far as I understand they are about to remove distutils after its deprecation, but, as a simple user of a library, what can I do?
I had a similar problem. My solution was:
I downloaded and installed exe file: https://pypi.org/project/pycurl/7.43.0.5/#files
In my virtual environment in file pyvenv.cfg i set "include-system-site-packages = true"
Deactivate and again activate virtual environment.

Can't install Tensorflow, because of Metadata error

EDIT: I already upgraded pip before initializing this process
I'm kind of stuck at this part where you have to use Protobuf to install Tensorflow. I did everything as those instructors in the Youtube video. I saw multiple videos, documents but none could help me out. Please help me...
The codes which were given in the terminal are down below
sudo apt install protobuf
After this I cloned the Tensorflow/models from the github repository and then I typed these as shown in that video
git clone https://github.com/tensorflow/models
utkarsh#ubuntu:~/tensorflow/models/research$ protoc object_detection/protos/*.proto --python_out=.
Then I copied the setup.py into object_detection subfolder as per instructions
cp object_detection/packages/tf2/setup.py .
and finally I ran the setup.py
python -m pip install .
This was the error code I received, and now I'm stuck
utkarsh#ubuntu:~/tensorflow/models/research$ python -m pip install .
Processing /home/utkarsh/tensorflow/models/research
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [14 lines of output]
Traceback (most recent call last):
File "<string>", line 36, in <module>
File "<pip-setuptools-caller>", line 14, in <module>
File "/home/utkarsh/anaconda3/lib/python3.7/site-packages/setuptools/__init__.py", line 18, in <module>
from setuptools.dist import Distribution
File "/home/utkarsh/anaconda3/lib/python3.7/site-packages/setuptools/dist.py", line 35, in <module>
from ._importlib import metadata
File "/home/utkarsh/anaconda3/lib/python3.7/site-packages/setuptools/_importlib.py", line 28, in <module>
disable_importlib_metadata_finder(metadata)
File "/home/utkarsh/anaconda3/lib/python3.7/site-packages/setuptools/_importlib.py", line 19, in disable_importlib_metadata_finder
for ob in sys.meta_path
File "/home/utkarsh/anaconda3/lib/python3.7/site-packages/setuptools/_importlib.py", line 20, in <listcomp>
if isinstance(ob, importlib_metadata.MetadataPathFinder)
AttributeError: module 'importlib_metadata' has no attribute 'MetadataPathFinder'
[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.
Any kind of help will be appreciated, Thank you!

pip3 install mysql-python failed with error code 1 in /tmp/pip-install-4nev4id4/mysql-python/

I am new in python on flask, when i try to install mysql-python by entering the
following command in terminal
pip3 install mysql-python
it shows the following error:
Collecting mysql-python
Using cached https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-4nev4id4/mysql-python/setup.py", line 13, in <module>
from setup_posix import get_config
File "/tmp/pip-install-4nev4id4/mysql-python/setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ModuleNotFoundError: No module named 'ConfigParser'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-4nev4id4/mysql-python/
and then I use this command
sudo apt install default-libmysqlclient-dev in terminal which has been suggested by many i checked on stackoverflow.
and then I retry to install mysql-python but also it is showing the same error, can anyone please help me.
mysql-python only supports Python 2.x, while you seem to be using Python 3. From the linked PyPI page:
MySQL-3.23 through 5.5 and Python-2.4 through 2.7 are currently
supported. Python-3.0 will be supported in a future release.
To connect to MySQL from Python 3 you can use other alternatives:
mysqlclient
mysql-connector-python
pymysql
cymysql
MySQL-python does not support python3. That is why you get this particular error
ModuleNotFoundError: No module named 'ConfigParser'
In python3 ConfigParser is renamed configparser
One option to connect to MySQL DB is official python connector
Another option is pyodbc
Other options are provided in other answers

Categories

Resources