running pip install from python 2.7.5 - python

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.

Related

Install python package for python2.7 with pip

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.

Installing Pip but require setuptools and getting syntax error

Trying to install pip without internet, so I downloaded the tar.gz package from pypi.org and when installing the pip setup file by running "python setup.py install" I get "No Module Named 'Setuptools'".
So I downloaded setuptools.tar.gz from pypi.org and ran the "python setup.py install" but this time I get a syntax error. Python version running is 3.5.2.
Traceback (most recent call last):
File "setup.py", line 7, in <module>
import setuptools
File "/home/insite/setuptools-57.0.0/setuptools/__init__.py", line 18, in <module>
from setuptools.dist import Distribution
File "/home/insite/setuptools-57.0.0/setuptools/dist.py", line 585
license_files: Optional[List[str]] = self.metadata.license_files
^
SyntaxError: invalid syntax
It looks like you're trying to install setuptools 57.0.0 on Python 3.5. As of setuptools 51.0.0,
Breaking Changes
#2435: Require Python 3.6 or later.
You need a version of setuptools that's 50.0.0 or older.
For what it's worth, the specific error you're getting is because of PEP 526, which was added to Python officially in 3.6. But even if you patched that somehow (and I don't recommend trying), you're likely to run into other problems. You just need an older setuptools or a newer Python.
Wrong setuptools version was used. Python 3.5 uses setuptools version 50.0.0 or older. Thanks to Silvio Mayolo.

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

Python 3.6 Error when installing pip install gearman

I have been trying to install gearman on python 3.6 but I'm getting this error:
$ pip install gearman
Collecting gearman
Using cached gearman-2.0.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-build-xmf1cqe7/gearman/setup.py", line 5, in <module>
from gearman import __version__ as version
File "/tmp/pip-build-xmf1cqe7/gearman/gearman/__init__.py", line 7, in <module>
from gearman.admin_client import GearmanAdminClient
File "/tmp/pip-build-xmf1cqe7/gearman/gearman/admin_client.py", line 4, in <module>
from gearman import util
File "/tmp/pip-build-xmf1cqe7/gearman/gearman/util.py", line 62
except select_lib.error, exc:
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-xmf1cqe7/gearman/
I am using Ubuntu 16.04 LTS
pip -V -> pip 9.0.1 from [my_project_folder]/venv/lib/python3.6/site-packages (python 3.6)
python --version -> Python 3.6.2
How do I fix that?
The gearman package does not support Python 3. Only python 2.4-2.7 are supported according to their setup.py. There is an open pull request to add python 3 support but it has been untouched for a year. I believe that Yelp! may have stopped supporting this library.
You use python3 and in python3
Use as instead:the raise syntax no longer accepts comma-separated arguments.
The gearman is not the Python 3 version, you can check the link https://pypi.python.org/pypi/gearman

Python3 won't recognize sqlite

I have python3 installed on linux. In the python interpreter, I tried
import sqlite3
and got
ImportError: No module named '_sqlite3'
so i installed sqlite with
sudo apt-get install libsqlite-dev
and then recompiled python according to the instructions in the README file:
cd ~/Python-3.4.2;
./configure;
make;
make test;
and during test there was an error saying
[ 97/389] test_sqlite
test_sqlite skipped -- No module named '_sqlite3'
and then when I finished the install and tried to run the same python code, I still got the same ImportError. What am I doing wrong?
---EDIT---
I tried
pip install pysqlite
and got this error, which seems to be an issue between Python2.7 and Python3.4:
Downloading/unpacking pysqlite
Downloading pysqlite-2.6.3.tar.gz (76kB): 76kB downloaded
Running setup.py (path:/tmp/pip_build_plat/pysqlite/setup.py) egg_info for package pysqlite
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip_build_plat/pysqlite/setup.py", line 85
print "Is sphinx installed? If not, try 'sudo easy_install sphinx'."
^
SyntaxError: Missing parentheses in call to 'print'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip_build_plat/pysqlite/setup.py", line 85
print "Is sphinx installed? If not, try 'sudo easy_install sphinx'."
^
SyntaxError: Missing parentheses in call to 'print'
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_plat/pysqlite
Storing debug log for failure in /home/plat/.pip/pip.log
After install libsqlite-dev you should install pysqlite
pip install pysqlite

Categories

Resources