python+pip install bson error - python

i want install 3rd library -> bson.
but error with next, who knows why?
# pip install bson
Collecting bson
Using cached bson-0.5.2.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-cP7YdW/bson/setup.py", line 8, in <module>
from pip import get_installed_distributions
ImportError: cannot import name get_installed_distributions
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-cP7YdW/bson/
system info:
# uname -a
Linux instance-says 4.9.0-6-amd64 #1 SMP Debian 4.9.82-1+deb9u3 (2018-03-02) x86_64 GNU/Linux
python and pip version info:
# python -V
Python 2.7.13
# pip --version
pip 10.0.0 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)

pip authors were warning for many years to not import pip. Finally at version 10 they restructured their code.
To continue using pip with packages that import pip you need pip version 9:
python -m pip install -U 'pip>=9,<10'
PS. There is already a bug report.

easy fix:
pip uninstall bson
pip uninstall pymongo
pip install pymongo

Try pip install --upgrade setuptools and run again.

Related

pip install/upgrade fails with SyntaxError

I want to upgrade pip
$ pip install --upgrade pip
I get this failure output.
$ pip install --upgrade pip
Collecting pip
Using cached https://files.pythonhosted.org/packages/da/f6/c83229dcc3635cdeb51874184241a9508ada15d8baa337a41093fab58011/pip-21.3.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-FErPSL/pip/setup.py", line 7
def read(rel_path: str) -> str:
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-FErPSL/pip/
You are using pip version 8.1.2, however version 21.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
What needs to be done here? Upgrading/installing any package with pip also suggests that upgrade pip version... but upgrading fails due to this...
I have tried the following without success
$ sudo python3 -m pip install -U pip
$ sudo python3 -m pip install -U setuptools
Looks like I have two installations of python in /bin/python and /bin/python3
python --version
Python 2.7.5
python3 --version
Python 3.6.8
You can try to execute the following commands:
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
python get-pip.py
pip install --upgrade setuptools
https://me.jinchuang.org/archives/1158.html
It seems like you have a Python version lower than 3.6. Pip has introduced new syntax on its latest releases, so upgrading from an old Python should fail.
From the output you posted, I can't see which is your Python version. So I'll give you the solution for the following cases:
You have a Python version lower than 3.6. Pip has dropped the support for your Python version. I recommend you to upgrade your Python version. Also, you can stay with and old pip (if you really need that old Python).
You have a newer Python version? Maybe you have many versions of Python installed. Verify that.

Pip installing packages incompatible to Python version

I'm trying to install numpy using docker, but I get the following error:
---> Running in 9f2546faf5d7
Collecting numpy
Downloading https://files.pythonhosted.org/packages/c5/63/a48648ebc57711348420670bb074998f79828291f68aebfff1642be212ec/numpy-1.19.4.zip (7.3MB)
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-xoiwnjj7/numpy/setup.py", line 68
f"NumPy {VERSION} may not yet support Python "
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-xoiwnjj7/numpy/
You are using pip version 8.1.1, however version 20.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
The command '/bin/sh -c pip3 install numpy' returned a non-zero code: 1
Here is the Dockerfile:
from ubuntu:16.04
run apt-get update && apt-get install -y \
python3-pip
run pip3 install \
numpy
The Python version is 3.5.2.
The issue seems to be that the f-string syntax was only introduced in Python 3.6. It seems weird to me that pip is installing packages that are not compatible with my version of Python, especially since pip apparently doesn't install versions of packages that were released before the installed Python version.
Is there an easy way to only install versions of packages that work with my version of Python?
Seems like this is an ubuntu 16.04 specific issue from this thread.
upgrade pip as root so pip can be upgraded if it is installed in some other locations.
To upgrade pip, run sudo python3 -m pip install --upgrade pip.

pip raise FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-install-_2yekith/pyqt5/setup.py' [duplicate]

pip3 install PyQt5
Collecting PyQt5
Using cached https://files.pythonhosted.org/packages/3a/fb/eb51731f2dc7c22d8e1a63ba88fb702727b324c6352183a32f27f73b8116/PyQt5-5.14.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.6/tokenize.py", line 452, in open
buffer = _builtin_open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-build-b2zw891b/PyQt5/setup.py'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-b2zw891b/PyQt5/
Then I downloaded zip folder from https://www.riverbankcomputing.com/software/pyqt/download5 and run:
python3 configure.py --qmake /home/oo/Qt/5.14.0/gcc_64/bin/qmake
make
sudo make install
Successful
>>> import PyQt5
>>> import PyQt5.QtCore
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'PyQt5.sip'
>>>
So I installed
pip3 install PyQt5.sip
pip3 install sip
Successful
but still getting same error No module named 'PyQt5.sip' for import PyQt5.QtCore
also tried PyQtChart but still error
pip3 install PyQtChart
Collecting PyQtChart
Using cached https://files.pythonhosted.org/packages/83/35/4f6328db9a31e2776cdcd82ef7688994c11e265649f503858f1913444ba9/PyQtChart-5.14.0-5.14.0-cp35.cp36.cp37.cp38-abi3-manylinux1_x86_64.whl
Collecting PyQt5>=5.14 (from PyQtChart)
Using cached https://files.pythonhosted.org/packages/3a/fb/eb51731f2dc7c22d8e1a63ba88fb702727b324c6352183a32f27f73b8116/PyQt5-5.14.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.6/tokenize.py", line 452, in open
buffer = _builtin_open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-build-gzep4mr7/PyQt5/setup.py'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-gzep4mr7/PyQt5/
I also downloaded zip folder from https://www.riverbankcomputing.com/software/pyqtchart/download and run:
python3 configure.py --qmake /home/oo/Qt/5.14.0/gcc_64/bin/qmake
Error: Unable to import PyQt5.QtCore. Make sure PyQt5 is installed.
QT screenshot::
My end goal is to run candlestick chart using pyqt5.
sudo python3 -m pip install pyqt5 pyqtchart
[sudo] password for oo:
The directory '/home/oo/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/oo/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: pyqt5 in /usr/lib/python3/dist-packages
Requirement already satisfied: pyqtchart in /usr/local/lib/python3.6/dist-packages
Requirement already satisfied: PyQt5-sip<13,>=12.7 in /home/oo/.local/lib/python3.6/site-packages (from pyqtchart)
but still getting same error:
Python 3.6.9 (default, Nov 7 2019, 10:44:02)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt5
>>> import PyQt5.QtCore
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'PyQt5.sip'
>>>
I think the initial pip install woes were due to PyQt5 switching to the manylinux2014 platform tag for the latest release (see the wheels on PyPI for 5.14.1 vs 5.14.0). Only pip versions >= 19.3 recognize this platform tag (ref), so if you happen to have an older version of pip, it would instead try to install from source.
Two easy options (to avoid the source install):
Update pip to the latest via pip3 install --upgrade pip
Install the previous release, which used manylinux1 (pip3 install pyqt5==5.14.0)
It seems that there is a bug in the latest version of PyQt5 to pypi so I installed a version 5.14:
sudo apt-get update && \
sudo apt-get autoclean
sudo apt-get update && sudo apt-get install \
-y --no-install-recommends \
python3-pip \
python3-setuptools
sudo python3 -m pip install pyqt5==5.14 pyqtchart==5.14
Copy the example of my previous answer in the main.py and then run:
python3 main.py
I recommend you search the folders and files generated by your failed attempts and delete them.
For my test I used the following Dockerfile
I also had the same issue installing PyQt5 (while trying to install ReText).
On Ubuntu 18.04 with Python 3.6.9 and Pip 9.0.1, I was able to pip install PyQt5 with these steps:
python3 -m venv env
source env/bin/activate
pip3 install pyqt5 --only-binary pyqt5
That was enough to make pip download the PyQt5-5.14.0-5.14.0-cp35.cp36.cp37.cp38-abi3-manylinux1_x86_64.whl binary wheel (that doesn't need/use the setup.py) instead of building from the source tarball.
According to https://pypi.org/project/PyQt5/#files, there are other binary wheels too, so hopefully that'll cover most platform needs.
Sometimes it is very difficult to install PyQt5 on Debian or Ubuntu Linux distro.
I was able to install it for python3 on my system running Debian 10 buster (stable).
I installed it with the apt package manager.
sudo apt-get update
sudo apt-get install python3-pyqt5
I have this problem too. It's because your pip is on older version and you should update it by using the below commands:
pip3 install setuptools wheel
pip3 install --upgrade pip
pip3 install --user pyqt5
For those who do not desperatly need 5.14, 5.12 can be a solution. This worked for me:
sudo python3 -m pip install pyqt5==5.12 pyqtchart==5.12
As the Question showed, you are downloading tar.zip file not wheel. Installing QT with pip is only allowed with wheel. Choose the version that has wheel file in PyPI homepage and matches to your Python version.
I had to build right version of sip from source in order to build desired version of PyQt5 from source and then I also got following error:
No module named 'PyQt5.sip'
and then
python3 -m pip install PyQt5.sip
solved the issue

Python : setuptools module is already installed but still shows import error

I am trying to install something using "python setup.py install" but it shows me this error :-
Traceback (most recent call last):
File "setup.py", line 3, in <module>
from setuptools import setup
ImportError: No module named setuptools
I have installed this missing module using "pip install setuptools". But still it shows me the same error .I have also tried to install this using "sudo apt-get install python-setuptools" but the problem still remains the same. Help me in this issue
If you have Python 2 >=2.7.9 or Python 3 >=3.4 installed from python.org, you will already have pip and setuptools, but will need to upgrade to the latest version:
On Linux or macOS:
pip install -U pip setuptools
On Windows:
python -m pip install -U pip setuptools
If you’re using a Python install on Linux that’s managed by the system package manager (e.g “yum”, “apt-get” etc…), and you want to use the system package manager to install or upgrade pip, then see link

Pip install error. Setuptools.command not found

I'm using a clean instance of Ubuntu server and would like to install some python packages in my virtualenv.
I receive the following output from the command 'pip install -r requirements.txt'
Downloading/unpacking pymongo==2.5.2 (from -r requirements.txt (line 7))
Downloading pymongo-2.5.2.tar.gz (303kB): 303kB downloaded
Running setup.py egg_info for package pymongo
Traceback (most recent call last):
File "<string>", line 3, in <module>
ImportError: No module named setuptools.command
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 3, in <module>
ImportError: No module named setuptools.command
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /home/redacted/env/build/pymongo
Storing complete log in /home/redacted/.pip/pip.log
Any Idea what's going on?
python version 2.7.3
pip version pip 1.4 from /home/redacted/env/lib/python2.7/site-packages (python 2.7)
Try installing:
sudo apt-get install python-setuptools
if this doesn't work try:
curl -O https://bootstrap.pypa.io/get-pip.py
python get-pip.py
Edit: If you have several (possible conflicting) python installations or environments, the following commands can be useful to debug which executables are being used:
which python
which pip
which easy_install
They should "match". It can happen for example that you have pip installing packages for an EPD or global distribution while the current python that is being used corresponds to a local environment (or something different), in which case it might not be able to see the installed packages.
had the same problem, solved it with
pip install -U setuptools
Elaborating #elyase's Answer.
First check for which python version you want to install setuptools.
Normally both python versions comes default with debian or any linux distro.
So, as per your requirement install setup tools using apt package manager
For python 2.x
sudo apt-get install python-setuptools
For python 3.x
sudo apt-get install python3-setuptools
These instructions solved the problem for me:
first enter these commands
pip install --upgrade pip
pip install --upgrade wheel
pip install setuptools
and then try to install the package that requires setuptools.

Categories

Resources