why do I get error installing some python packages? [duplicate] - python

According to Django 2.0 release notes Django 2.0 onwards will only support python 3, making the 1.11.X the last release series to support python 2.
See quote from the release notes page:
Django 2.0 supports Python 3.4, 3.5, and 3.6. We highly recommend and only officially support the latest release of each series.
The Django 1.11.x series is the last to support Python 2.7.
However when running pip2 install Django, django version 2 is being installed (which then fails because it assumes functionality not available in python 2):
(venv-crap) mbp15:server nir$ pip2 install django
Collecting django
Downloading Django-2.0.tar.gz (8.0MB)
100% |████████████████████████████████| 8.0MB 177kB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/PATH/django/setup.py", line 32, in <module>
version = __import__('django').get_version()
File "django/__init__.py", line 1, in <module>
from django.utils.version import get_version
File "django/utils/version.py", line 61, in <module>
#functools.lru_cache()
AttributeError: 'module' object has no attribute 'lru_cache'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/PATH/django/
I know I can manually specify requirement version below 2, making pip install a version valid for python 2, however that will complicate the installation process if I want to support both python2 and python3, and would have assumed pip will know to install only versions compatible with the python it's running from.
My questions, therefore, as the following:
Why is pip attempting to install Django2 with python2 instead of automatically picking the last compatible version? Isn't that part of pips capabilities?
Is there a way to make a single requirements.txt that will install Django<2.0 when running from python2 and Django>=2.0 when running with python3?

Why is pip attempting to install Django2 with python2 instead of automatically picking the last compatible version? Isn't that part of pips capabilities?
As Alasdair pointed out in the comments already, this is a known bug in Django: bug #28878.
Is there a way to make a single requirements.txt that will install Django<2.0 when running from python2 and Django>=2.0 when running with python3?
You can use the environment markers (see PEP 508):
# requirements.txt
django>=1.11,<2.0; python_version<"3.4"
django>=2.0; python_version>="3.4"
This will install one and skip another django dependency, depending on what python you are using:
$ pip2.7 install -r requirements.txt
Ignoring django: markers 'python_version >= "3.4"' don't match your environment
Collecting django<2.0 (from -r requirements.txt (line 1))
Downloading Django-1.11.8-py2.py3-none-any.whl (6.9MB)
...
$ pip3.6 install -r requirements.txt
Ignoring django: markers 'python_version < "3.4"' don't match your environment
Collecting django>=2.0 (from -r requirements.txt (line 2))
Using cached Django-2.0-py3-none-any.whl
...

Related

Python pip install cannot find module

So I am trying to install pylint using pip, as my work machine is offline I have downloaded pylint using pip and transferred this using a CD. As part of pylint download it also brought down asteroid, colorama, isort, lazy_object_proxy, McCabe, six, typed ast and wrapt.
However when running the install for pylint using the following command inside the directory with all the above files in:
python -m pip install --no-index --find-links . -r requirements.txt
This starts to work with it collecting pylint, isort and a couple of others, however after collecting asteroid it goes to collect lazy object proxy (which is in the directory) and gives the following error:
Could not find a version that satisfies the requirement lazy-object-proxy (from asteroid<3,>=2.2.0->pylint->-r requirements.txt (line 1)) (from versions: ) No matching distribution found for lazy-object-proxy (from asteroid<3,>=2.2.0->pylint->-r requirements.txt (line 1))
The version of lazy object proxy downloaded is 1.4.1
Im fairly new to this so maybe there is something in this error that highlights why it doesn't see or like the version that is downloaded and in the directory, any help would be much appreciated.
OS is windows 7, running python version 3.6.0
NOTE: even trying to just install lazy object proxy on its own fails saying it doesn't exist, its like its not there although it is in the folder.

awscli not working on OS X, keep getting ImportError: No module named awscli_plugin_endpoint

I recently broke my awscli installation by doing a brew upgrade. I keep getting
ImportError: No module named awscli_plugin_endpoint
regardless of what python version I use.
Here's what I've tried already:
current python version coming with brew using brew install awscli,
pyenv with 2.7.14 and 3.6.4,
virtualenv using this gist,
pyenv with this other gist.
install the tarballs manually from 1.14.65 - to 1.14.62.
No matter what I do, it always complains about
No module named awscli_plugin_endpoint
I've already wiped the complete brew install, wiped all pyenvs, removed dot dirs .local, .pyenv. The only thing that is still there is the system install python coming with OS X.
Running OS X 10.13.3, using zsh.
What is wrong here?
Example stacktrace from Python 2.7:
$ aws --version
Traceback (most recent call last):
File "/Users/dhiller/pyenvs/aws/bin/aws", line 27, in <module>
sys.exit(main())
File "/Users/dhiller/pyenvs/aws/bin/aws", line 23, in main
return awscli.clidriver.main()
File "/Users/dhiller/pyenvs/aws/lib/python2.7/site-packages/awscli/clidriver.py", line 58, in main
driver = create_clidriver()
File "/Users/dhiller/pyenvs/aws/lib/python2.7/site-packages/awscli/clidriver.py", line 69, in create_clidriver
event_hooks=emitter)
File "/Users/dhiller/pyenvs/aws/lib/python2.7/site-packages/awscli/plugin.py", line 44, in load_plugins
modules = _import_plugins(plugin_mapping)
File "/Users/dhiller/pyenvs/aws/lib/python2.7/site-packages/awscli/plugin.py", line 58, in _import_plugins
plugins.append(__import__(path))
ImportError: No module named awscli_plugin_endpoint
The solution was simple - just use the pip that's matching the python installation to install the endpoint manually:
# this also installs python as a dependency
$ brew install awscli
$ /usr/local/opt/awscli/libexec/bin/pip install awscli-plugin-endpoint
$ aws --version
aws-cli/1.14.60 Python/3.6.4 Darwin/17.4.0 botocore/1.9.13
Or remove the plugin entry in ~/.aws/config:
[plugins]
endpoint = awscli_plugin_endpoint
I have to admit, this took me longer than it should have, and this is probably not the best way to go about it, but my version of aws doesn't have pip, so I just copied over the plugin (needed admin priviledges to do this)
C:\Users\blackstrype>pip install awscli-plugin-endpoint
Requirement already satisfied: awscli-plugin-endpoint in *__c:\users\blackstrype\appdata\local\programs\python\python38-32\lib\site-packages__* (0.4)
Requirement already satisfied: awscli>=1.11.0 in c:\users\blackstrype\appdata\local\programs\python\python38-32\lib\site-packages (from awscli-plugin-endpoint) (1.18.138)
Requirement already satisfied: docutils<0.16,>=0.10 in c:\users\blackstrype\appdata\local\programs\python\python38-32\lib\site-packages (from awscli>=1.11.0->awscli-plugin-endpoint) (0.15.2)
Requirement already satisfied: colorama<0.4.4,>=0.2.5; python_version != "3.4" in c:\users\blackstrype\appdata\local\programs\python\python38-32\lib\site-packages (from awscli>=1.11.0->awscli-plugin-endpoint) (0.4.3)
Copy
C:\users\blackstrype\appdata\local\programs\python\python38-32\lib\site-packages\awscli-plugin-endpoint*
to
C:\Program Files\Amazon\AWSCLI\runtime\Lib\site-packages

Error when installing dmgbuild with pip.

I am trying to install dmgbuild with pip and I receive the error below:
AttributeError: 'str' object has no attribute 'decode'
Windows 10
Command Prompt (Admin)
pip version 9.0.1
C:>pip install dmgbuild
Collecting dmgbuild
Using cached dmgbuild-1.3.0.tar.gz
Collecting ds_store>=1.1.0 (from dmgbuild)
Using cached ds_store-1.1.0.tar.gz
Collecting mac_alias>=2.0.1 (from dmgbuild)
Using cached mac_alias-2.0.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\rpanczer\AppData\Local\Temp\pip-build-gvy3qj3a\mac-alias\setup.py", line 5, in
longdesc = f.read().decode('utf-8')
AttributeError: 'str' object has no attribute 'decode'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\rpanczer\AppData\Local\Temp\pip-build-gvy3qj3a\mac-alias\
str.decode no longer exists in python 3.x
The error is due to mac_alias, which dmgbuild depends on,is not compatible to python 3 somehow.
You can check out mac_alias homepage.
I just tested everything is okay if you are using python 2.7.
Try to specify your python interpreter firstly before writing commands, this may help you in the case you have more than one version installed.
C:\ python3 pip install dmgbuild
Also try to use -m command in addition to pip install, it provides root access to python command prompt.
C:\ python3 -m pip install dmgbuild
In case neither of the methods above works for you, check if your python interpreter is already added the PATH variable.

Failed to install wsgiref on Python 3

I have a problem installing wsgiref:
$ python --version
Python 3.6.0 :: Anaconda 4.3.1 (x86_64)
$ pip --version
pip 9.0.1 from /anaconda/lib/python3.6/site-packages (python 3.6)
My requirement.txt file are shown as below.
numpy==1.8.1
scipy==0.14.0
pyzmq==14.3.1
pandas==0.14.0
Jinja2==2.7.3
MarkupSafe==0.23
backports.ssl-match-hostname==3.4.0.2
gnureadline==6.3.3
ipython==2.1.0
matplotlib==1.3.1
nose==1.3.3
openpyxl==1.8.6
patsy==0.2.1
pyparsing==2.0.2
python-dateutil==2.2
pytz==2014.4
scikit-learn==0.14.1
six==1.7.3
tornado==3.2.2
wsgiref==0.1.2
statsmodels==0.5.0
when I run pip install -r requirement.txt, I got this error
Collecting wsgiref==0.1.2 (from -r requirements.txt (line 20))
Using cached wsgiref-0.1.2.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/xs/y0pbzxkn7gqcdtrz4cpxtwrw0000gn/T/pip-build-hkiqbu1j/wsgiref/setup.py", line 5, in <module>
import ez_setup
File "/private/var/folders/xs/y0pbzxkn7gqcdtrz4cpxtwrw0000gn/T/pip-build-hkiqbu1j/wsgiref/ez_setup/__init__.py", line 170
print "Setuptools version",version,"or greater has been installed."
^
SyntaxError: Missing parentheses in call to 'print'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/xs/y0pbzxkn7gqcdtrz4cpxtwrw0000gn/T/pip-build-hkiqbu1j/wsgiref/
I have tried to run pip install --upgrade setuptools and sudo easy_install -U setuptools but neither works. How can I solve this problem?
wsgiref is already been included as a standard library in Python 3...
So in case if you are trying with Python 3 just go ahead and import wsgiref thats it.
According to this line SyntaxError: Missing parentheses in call to 'print', I think it needs Python 2.x to run the setup.py. Whether to use parentheses in print is the different syntax of Python 2 and Python 3.
This is the solution from the Github issue:
There are a few fixes that will get you running, in order of least work to most:
Switch over to python2.7 for your will installs.
Try to upgrade wsgiref with pip install --upgrade wsgiref, and see if the latest version works with your setup, and with will (if it doesn't, you'd notice the http/webhooks stuff not working.
If you try 2) and it works, submit a PR here with the upgraded version in requirements.txt. (You can find out what versions you've got by using pip freeze).
You can find more about the syntax difference here
Solution:
Flask-restful is deprecated, use version flask-restx

Syntax error when installing csc-pysparse

I am new to Python and I am trying to install recsys package.
http://ocelma.net/software/python-recsys/build/html/installation.html
For this i need to install some pre-requiste packages, so i have to run this using pip
pip install csc-pysparse networkx divisi2
But whenever i run this i get the following in logs
Collecting csc-pysparse
Using cached csc-pysparse-1.1.1.4.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\64\AppData\Local\Temp\pip-build-wn7_65_9\csc-pysparse\
setup.py", line 33
print 'setuptools module not found.'
^
SyntaxError: Missing parentheses in call to 'print'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\i054564\
AppData\Local\Temp\pip-build-wn7_65_9\csc-pysparse\
I checked that setuptools exist in my python installation here
C:\Python34\lib\site-packages
I have ran everything from unstinalling setuptools to install it again, upgrade command, but it does not work.
Not able to figure out why setuptools is not found. Is it not found in the path of where pip resolves it from ?
cheers,
Saurav
The code triggering the error is Python 2-specific and is illegal in Python 3.
Apparently, csc-pysparse doesn't support Python 3 (its README only mentions 2.6) and looks abandoned (6 years since last commit).
Some guys out there suggest replacing it with SciPy.
The error is coming from the installation code of recsys package. In order to avoid this error, you need to install setuptools separately.
For debian machines, the below command will work.
sudo apt-get install python3-setuptools
For other machines, please checkout installation instructions at the link
Once setuptools package is installed, you can proceed with csc-pysparse installation.

Categories