Install python package for python2.7 with pip - python

I am trying to install pre-commit for python2.7 with pip 8.1.2.
If i do pip install --user pre-commit or ´python -m pip install --user pre-commit´ it keeps trying to load pre-commit3.0.2 and failing.
So i tried to find the most recent version that still supports python2.7 (by manually going through the version history, is there not better way?) and that is 1.21.0.
But even when i do pip install --user pre-commit==1.21.0 it fails due to
Collecting virtualenv>=15.2 (from pre-commit==1.21.0)
Using cached https://files.pythonhosted.org/packages/7b/19/65f13cff26c8cc11fdfcb0499cd8f13388dd7b35a79a376755f152b42d86/virtualenv-20.17.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-mjJnKQ/virtualenv/setup.py", line 4, in <module>
raise RuntimeError("setuptools >= 41 required to build")
RuntimeError: setuptools >= 41 required to build
which i assume is because virtualenv-20.17.1 requires python3

Yes, I think pre-commit is not supported for Python 2.7 and starts only in 3.7 but you can write a custom hook or any other tools that you are using for linting based on the IDE you are using.The hook would need to check for any errors in the code before committing, and if any errors are found, it should fail the commit and display a warning message.

Related

Trying to install a program and got an error asking a Python version that is already installed, and also a pip error

As the title says, I am trying to install a program that has a couple of dependecies that demand a specific Python version (>= 3.7). I do not have admin rights, so I can't use sudo. The Python version installed is 2.7. Because of that, I used virtualenv to install and execute Python 3.9.5.
I executed venv, and checked the Python and pip versions:
which python
/home/honda/venv_python-3.9.5/bin/python
which pip
/home/honda/venv_python-3.9.5/bin/pip
I even checked the version using:
python
Python 3.9.5 (default, May 10 2021, 13:50:25)
Which, as I understand, means that I have the correct Python/pip versions.
However, when I try to install the program, I get this:
./install.sh ../Programs/
Installing darwin binary...
Installing oma...
Installing libraries...
creating virtualenv for hog_bottom_up
Collecting numpy (from -r ../Programs//OMA/OMA.2.4.2/hog_bottom_up/requirements.txt (line 1))
Using cached https://files.pythonhosted.org/packages/f3/1f/fe9459e39335e7d0e372b5e5dcd60f4381d3d1b42f0b9c8222102ff29ded/numpy-1.20.3.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-3_2_atp3/numpy/setup.py", line 30, in <module>
raise RuntimeError("Python version >= 3.7 required.")
RuntimeError: Python version >= 3.7 required.
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-3_2_atp3/numpy/
You are using pip version 8.1.1, however version 21.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Cannot install python dependencies for hog-bottom-up inference algorithm
cannot create virtual environment for hog_bottom_up
To be honest, I don't know what is happening here. Is there something I am missing? I am not experienced in using virtualenv (I previously used another computer, one that I could use sudo, so I never had any problems like this, and I did install this same program there.)
Is there anything I can try? I guess could reach out to the admin and ask them to install the program for me, but I'd rather not do that yet.
Thank you!

can not install Ropper with pip on Linux

I am trying to write some script which requires ropper. (install only via pip)
How can i fix this problem?
I am trying to install it on linux, tried to upgrade setuptools, install old version and followed this, only one topic, which i found:
the link!
This is the error message:
$ pip install ropper
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting ropper
Using cached https://files.pythonhosted.org/packages/94/b1/922dfab5083ff439ce70358c7f3e49185c54e6ea6ee2bb7cd292e63eac06/ropper-1.12.1.tar.gz
Collecting filebytes>=0.9.18 (from ropper)
Using cached https://files.pythonhosted.org/packages/0b/3a/9fc0c62bd74583137a8bbc3c8020d6a8234b9cf8bc1e99fe929688b19093/filebytes-0.9.20.tar.gz
ERROR: Complete output from command python setup.py egg_info:
ERROR: Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-d44HeD/filebytes/setup.py", line 3, in <module>
from pathlib import Path
ImportError: No module named pathlib
----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-d44HeD/filebytes/
filebytes==0.9.20 release is not compatible with Python 2; the package maintainer already fixed this, but the new version is not yet uploaded to PyPI. Restrict filebytes to previous version for now:
$ pip install "filebytes<0.9.20" ropper
Once next version (0.9.21) is released, you can update it if you want:
$ pip install --upgrade "filebytes>0.9.20"

can not install specific version of nltk

for a specific reason I need to install nltk 2.09b in python 2.7 version. But whenever I execute the following command,
pip2 install nltk==2.0b9
I get the following error:
Collecting nltk==2.0b9
Using cached https://files.pythonhosted.org/packages/ea/b3/4c5157bf034437905fbbd3c80e58c8b4a22cf3400db0bdf19dae3079a732/nltk-2.0b9.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
IOError: [Errno 2] No such file or directory: '/private/var/folders/3b/yskb8jks10lf_pqvv1sy7v740000gn/T/pip-install-63jdDZ/nltk/setup.py'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/3b/yskb8jks10lf_pqvv1sy7v740000gn/T/pip-install-63jdDZ/nltk/
But if I run without any version specification I don't get an error. like the following:
pip2 install nltk;
How can I solve this issue?
First thing: using anaconda, you probably have a recent enough pip and setuptools and should use conda itself to update those. With anaconda, conda install is the primary resource for installing anaconda-provided packages. Then, "2.0b9" is a beta release (as indicated by the "b9") and might suffer from a configuration problem for the install. The setup.py file is not located at the root of the downloaded archive file, I suppose that creates the problem.
Use this
pip3.6 install nltk==version

Read the Docs: Distutils2 error during installation

I try to install local instance of Read the Docs on my Win10
When I follow this documentation:
http://docs.readthedocs.io/en/latest/install.html
and type:
pip install -r requirements.txt
I get this error:
Collecting Distutils2==1.0a3 (from -r requirements/pip.txt (line 65))
Using cached Distutils2-1.0a3.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\USER\AppData\Local\Temp\pip-build-xseiavup\Distutils2\setup.py", line 9, in <module>
from distutils2.util import find_packages
File "C:\Users\USER\AppData\Local\Temp\pip-build-xseiavup\Distutils2\distutils2\util.py", line 174
except KeyError, var:
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\USER\AppData\Local\Temp\pip-build-xseiavup\Distutils2\
Anyone know this error?
My pip version: 8.1.2;
python: 3.5
Is it possible you are running the Python 2 pip? The error message clearly indicates that the code is being executed under Python 3 but has Python 2 syntax. Do you get better results with
python -m pip install -r requirements.txt
I wonder? If not then verify that
python
runs version 3.5 ...
Oh. I just checked and the disutils2 page on PyPI says
Distutils2 development is stopped.
tl;dr: keep using setuptools and pip for now, don’t use distutils2.
It looks like there was never a Python 3 version. Looks like you might need to update your code.

running pip install from python 2.7.5

I have a CentOS server (5.6) which has Python 2.4.3 on it. I have another local installation of Python (2.7.5) installed in /opt and soft-links created as follows /usr/local/bin/python2.7 and /usr/local/python2.7. I want to install python-requests using pip. While installing using the command pip install requests, I get the following error:
root ~/ff_test_ff # pip install requests
Unpacking ./requests
Running setup.py egg_info for package from file:///root/ff_test_ff/requests
Traceback (most recent call last):
File "<string>", line 14, in ?
File "/tmp/pip-MM685m-build/setup.py", line 6, in ?
import requests
File "requests/__init__.py", line 58
from . import utils
^
SyntaxError: invalid syntax
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 14, in ?
File "/tmp/pip-MM685m-build/setup.py", line 6, in ?
import requests
File "requests/__init__.py", line 58
from . import utils
^
SyntaxError: invalid syntax
----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /root/.pip/pip.log
I'm assuming it's still trying to use Python 2.4. I checked here which says 2.4 isn't supported. So how do I run the pip install command but use python2.7 instead?
you need to set the PYTHONPATH / PYTHONHOME like here
you can also try to install virtualenv
You probably should (re)install a new version of pip explicitly for the new Python version. On pip installation instructions page it says that
pip works with CPython versions 2.6, 2.7, 3.1, 3.2, 3.3 and also pypy.
While installing, be sure to use the newer version of Python instead of the old one.

Categories

Resources