Can't install Tensorflow, because of Metadata error - python

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!

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.

Can't install python packages on my ubuntu virtual machine

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>

(raspberrypi) "pandas" Requirement already satisfied, but No module named 'pandas', when I use it

(raspberrypi) "pandas" Requirement already satisfied, but No module named 'pandas', when I run python script ("import pandas as pd")
I use raspberrypi 4 ; 32 bit, linux run python
I run: in virtual environment
(venv) joy#raspberrypi: sudo pip install pandas
(venv) joy#raspberrypi: ython excel_to_mDB.py
(venv) joy#raspberrypi:/media/joy/DATA $ sudo pip install pandas
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: pandas in /usr/lib/python3/dist-packages (1.1.5)
(venv) joy#raspberrypi:/media/joy/DATA $ python excel_to_mDB.py
Traceback (most recent call last):
File "/media/joy/DATA/excel_to_mDB.py", line 3, in <module>
import pandas as pd
ModuleNotFoundError: No module named 'pandas'
solving on process:
after I do pip install pandas
(venv) joy#raspberrypi:/media/joy/DATA $ pip install pandas
(venv) joy#raspberrypi:/media/joy/DATA $ python excel_to_mDB.py
(venv) joy#raspberrypi:/media/joy/DATA $ pip install pandas
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pandas
Using cached pandas-1.5.1.tar.gz (5.2 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [53 lines of output]
Traceback (most recent call last):
File "/tmp/pip-build-env-d93of2e3/overlay/lib/python3.9/site-packages/numpy/core/__init__.py", line 22, in <module>
from . import multiarray
File "/tmp/pip-build-env-d93of2e3/overlay/lib/python3.9/site-packages/numpy/core/multiarray.py", line 12, in <module>
from . import overrides
File "/tmp/pip-build-env-d93of2e3/overlay/lib/python3.9/site-packages/numpy/core/overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ImportError: libcblas.so.3: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/joy/myproject/venv/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 351, in <module>
main()
File "/home/joy/myproject/venv/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 333, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/home/joy/myproject/venv/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
File "/tmp/pip-build-env-d93of2e3/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 338, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
File "/tmp/pip-build-env-d93of2e3/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 320, in _get_build_requires
self.run_setup()
File "/tmp/pip-build-env-d93of2e3/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 483, in run_setup
super(_BuildMetaLegacyBackend,
File "/tmp/pip-build-env-d93of2e3/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 335, in run_setup
exec(code, locals())
File "<string>", line 18, in <module>
File "/tmp/pip-build-env-d93of2e3/overlay/lib/python3.9/site-packages/numpy/__init__.py", line 140, in <module>
from . import core
File "/tmp/pip-build-env-d93of2e3/overlay/lib/python3.9/site-packages/numpy/core/__init__.py", line 48, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.9 from "/home/joy/myproject/venv/bin/python"
* The NumPy version is: "1.19.3"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: libcblas.so.3: cannot open shared object file: No such file or directory
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
(venv) joy#raspberrypi:/media/joy/DATA $ python excel_to_mDB.py
Traceback (most recent call last):
File "/media/joy/DATA/excel_to_mDB.py", line 3, in <module>
import pandas as pd
ModuleNotFoundError: No module named 'pandas'
You are installing the pandas using the command sudo pip install pandas which will install pandas into the root folder /usr/lib/python3/dist-packages see the logs in your command. You need to install pandas into the virtual environment. So install pandas without sudo.
pip install pandas

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.

Categories

Resources