With PyCharm I tried to add a project interpreter for my Docker container
but then I get this incomprehensible error.
Invalid requirement: 'redis\>=2.10.5'
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 82, in __init__
req = Requirement(req)
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/packaging/requirements.py", line 96, in __init__
requirement_string[e.loc:e.loc + 8]))
InvalidRequirement: Invalid requirement, parse error at "'\\>=2.10.'
What can I do about it?
From the official documentation of pip:
https://pip.pypa.io/en/stable/reference/pip_install/#examples
$ pip install SomePackage # latest version
$ pip install SomePackage==1.0.4 # specific version
$ pip install 'SomePackage>=1.0.4' # minimum version
It seems you have to use apostrophes for a minimum version.
Backslash in redis\>=2.10.5 is the culprit of the problem. Replace redis\>=2.10.5 with 'redis>=2.10.5'.
Related
I am not able to run $ pip list using pip 19.0.1 from /usr/local/lib/python3.6/dist-packages/pip (python 3.6).
$ pip list
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2584, in version
return self._version
File "/usr/local/lib/python3.6/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2691, in __getattr__
raise AttributeError(attr)
AttributeError: _version
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/base_command.py", line 176, in main
status = self.run(options, args)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/commands/list.py", line 148, in run
self.output_package_listing(packages, options)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/commands/list.py", line 205, in output_package_listing
data, header = format_for_columns(packages, options)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/commands/list.py", line 271, in format_for_columns
row = [proj.project_name, proj.version]
File "/usr/local/lib/python3.6/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2589, in version
raise ValueError(tmpl % self.PKG_INFO, self)
ValueError: ("Missing 'Version:' header and/or METADATA file", Unknown [unknown version] (/usr/local/lib/python3.6/dist-packages))
I'm working on a fresh virtual machines where these commands have been run, with the final command installing something I had cloned from github.
apt-get install -y python3 python3-pip python3-dev
python3 -m pip install --upgrade pip
pip3 install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz#egg=en_core_web_sm-2.0.0
sudo -H pip3 install -e /vagrant
The problem is that there are folders in my Python library that start with a hyphen, and those are causing errors. I wasn't sure what to rename them to, so I deleted them. This will probably cause me problems in the future, but it resolved the problem for this thread.
Assume that the problematic folder is named -bad_folder. These commands should solve it:
cd /usr/local/lib/python3.6/dist-packages
rm -rf ./-bad_folder
the ./ before the name of the bad folder is important so the command line recognizes that it's a file and not an option for the command.
If anyone has a better solution than deleting the folders, please let me know.
Update: The folder I had with the leading hyphen was named -pacy; it appears that this was an artifact of an incomplete installation of spaCy (a Python package). I gave my VM more memory and installed it again, and the -pacy file wasn't there.
The pip command often refers to Python version 2.
Try pip3 instead.
I can't install python-ldap via pip, I get the following error:
$ sudo pip3.4 install python-ldap
Downloading/unpacking python-ldap
Downloading python-ldap-2.4.19.tar.gz (138kB): 138kB downloaded
Running setup.py (path:/tmp/pip_build_root/python-ldap/setup.py) egg_info for package python-ldap
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip_build_root/python-ldap/setup.py", line 53
print name + ': ' + cfg.get('_ldap', name)
^
SyntaxError: invalid syntax
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip_build_root/python-ldap/setup.py", line 53
print name + ': ' + cfg.get('_ldap', name)
^
SyntaxError: invalid syntax
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/python-ldap
Storing debug log for failure in /home/nima/.pip/pip.log
Any ideas how to resolve this?
It seems that your python-ldap is implemented in Python-2.X but you're using Python-3.X (Print Is A Function in python 3). Therefore, you need to install a newer version of this library that supports Python-3.X or install the library in python-2.X which is not recommended.
You can install the proper version for Python-3.X though using following command:
# if pip3 is the default pip alias for python-3
pip3 install python3-ldap
# otherwise
pip install python3-ldap
Also here is the link of PiPy package for further information. https://pypi.python.org/pypi/python3-ldap/0.9.8.4/
You can install python-ldap which is implemented for python3
pip install python3-ldap
Have tried many things, but keep getting this error after multiple attempts to update python, pip, etc. I am on OS X running 10.9.5.
CMD% eb
Traceback (most recent call last):
File "/usr/local/bin/eb", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
pkg_resources.DistributionNotFound: python-dateutil>=2.1,<3.0.0
I was experiencing a similar error when trying to run eb, though not for dateutil...
Traceback (most recent call last):
File "/usr/local/bin/eb", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: requests>=2.6.1,<2.7
For me the solution was to update setuptools:
sudo pip install --upgrade setuptools
Hope that helps somebody.
Use the following command:
pip install awsebcli
It will automatically upgrade all dependecies of awsebcli.
use the following command
sudo pip install python-dateutil
to upgrade it
Pip is probably linked to a different version of python then standard.
You should try installing pip using
python get-pip.py
(You can download get-pip.py from the pip website)
Otherwise, You can see which Python everything is linked too.
which python
head -1 $(which eb)
head -1 $(which pip)
You can change to shebang line in the eb script to match pip and it should all work.
You can also install using a virtualenv (pythons recommended way of installing)
virtualenv ~/ebenv
source ~/ebenv/bin/activate
pip install awsebcli
deactivate
sudo ln -s ~/ebenv/bin/eb /usr/local/bin/
in my case on mac osx 10.10, I had to reinstall.
sudo pip install python-dateutil
Just in case some runs into this type of error. check the last paragraph in the trace for the kind of error that it is being raised. In my case, this was:
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (six 1.4.1
(/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python),
Requirement.parse('six>=1.5'), set(['python-dateutil']))
I had the exact same issue, for me, the eb script was using the wrong python. To solve it I just modified the eb script:
> which eb
/usr/local/bin/eb
> sudo vim /usr/local/bin/eb
## Change the first line from '#!/usr/bin/python' to '#!/usr/local/bin/python'
After restarting the terminal, everything work as expected.
From the raised error in your log, it needs python-dateutil>=2.1.
So you need to make sure that version is installed and install it if not. I had similar issue, and the solution (in my case) is:
$ pip install --ignore-installed python-dateutil==2.2
First, I installed lxml without using pip (Python 2.7.2 on Mac OS 10.6.8). Then, I read this post and I installed it again using pip (sudo pip install lxml). I still had a problem:
I can import lxml (import lxml) but I cannot use from lxml import etree. I have this error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lxml-2.3.3-py2.7-macosx-10.6-intel.egg/lxml/etree.so, 2): Symbol not found: _htmlParseChunk
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lxml-2.3.3-py2.7-macosx-10.6-intel.egg/lxml/etree.so
Expected in: flat namespace
in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lxml-2.3.3-py2.7-macosx-10.6-intel.egg/lxml/etree.so
Then, I tried to install lxml from source following these instructions, and I have this error message:
checking whether we are cross compiling... configure: error: in `/Users/my_name/Applications/lxml/lxml-2.2.2/build/tmp/libxml2-2.7.8':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
Traceback (most recent call last):
File "setup.py", line 115, in <module>
STATIC_CFLAGS, STATIC_BINARIES),
File "/Users/my_name/Applications/lxml/lxml-2.2.2/setupinfo.py", line 50, in ext_modules
libxslt_version=OPTION_LIBXSLT_VERSION)
File "/Users/my_name/Applications/lxml/lxml-2.2.2/buildlibxml.py", line 198, in build_libxml2xslt
call_subprocess(configure_cmd, cwd=libxml2_dir, **call_setup)
File "/Users/my_name/Applications/lxml/lxml-2.2.2/buildlibxml.py", line 158, in call_subprocess
raise Exception('Command "%s" returned code %s' % (cmd_desc, returncode))
Exception: Command "./configure --without-python --disable-dependency-tracking --disable-shared --prefix=/Users/my_name/Applications/lxml/lxml-2.2.2/build/tmp/libxml2" returned code 1
Finally, I followed the second advise of this answer and I used the command line sudo STATIC_DEPS=true /usr/bin/easy_install-2.7 lxml. It installed lxml on the Apple-supplied system Python 2.7, and not on the version I'm currently using. The positive point: if I run the Apple-Python, I can from lxml import etree.
Negative point: I still don't know how to install lxml on another version of python. Any idea?
I'm currently using /Library/Frameworks/Python.framework/Versions/2.7/bin/python.
You need to install a separate easy_install for the version of Python you are using. See the answer here for more details. Then you can run the easy_install command using it:
STATIC_DEPS=true easy_install-2.7 lxml
UPDATE: From your comments, you now are reporting a permission error showing yet another Python path, one that appears to be a MacPorts-installed Python: /opt/local/Library/Frameworks. You need to figure out which Python you want to use. If, in fact, you want to use the MacPorts one, then simply install the MacPorts-provided lxml port. That's the easiest solution.
$ sudo port selfupdate
$ sudo port install py27-lxml
Otherwise, you need to install easy_install with the other (python.org?) Python 2.7.2. I would recommend to use Distribute, the more modern fork of `setuptools' and you need to ensure you are using the right Python:
$ curl -O http://python-distribute.org/distribute_setup.py
$ export PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
$ which python2.7 # should be in the path above
$ python2.7 distribute_setup.py
$ STATIC_DEPS=true easy_install-2.7 lxml
Easy_install and Pip doesn't work anymore on python 2.7, when I try to do:
sudo easy_install pip
I get:
Traceback (most recent call last):
File "/usr/bin/easy_install", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/bin/lib/python2.7/site-packages/distribute-0.6.19-py2.7.egg/pkg_resources.py", line 2713, in <module>
parse_requirements(__requires__), Environment()
File "/usr/bin/lib/python2.7/site-packages/distribute-0.6.19-py2.7.egg/pkg_resources.py", line 584, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: distribute==0.6.15
And when I try:
sudo pip install [package]
I get:
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/bin/lib/python2.7/site-packages/distribute-0.6.19-py2.7.egg/pkg_resources.py", line 2713, in <module>
parse_requirements(__requires__), Environment()
File "/usr/bin/lib/python2.7/site-packages/distribute-0.6.19-py2.7.egg/pkg_resources.py", line 584, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==0.8.2
I've already install both of them (and yes, first deleted them), but no result...
Thanks!
(I tried already this post)
I had this issue where python's distribute package wasn't installed for some reason. After following the instructions on python-distribute, i got it working.
install the distribute package as follows:
$ wget https://web.archive.org/web/20100225231201/http://python-distribute.org/distribute_setup.py
$ python distribute_setup.py
EDIT: http://python-distribute.org/distribute_setup.py no longer works:
hopefully this will resolve your problem with running
$ sudo easy_install
Happy Coding!
If you installed a new version of easy_install through Distribute, the new command may have been installed in another directory, most likely /usr/local/bin/. But the traceback shows you were using /usr/bin/easy_install. Try this:
sudo /usr/local/bin/easy_install ...
Try
sudo easy_install Distribute
and if that exists, but is too old
sudo easy_install -U Distribute
Looks like either Distribute/setuptools (it's old name) is messed up or Python package settings. If either of these do not help, try removing the full Python 2.7 installation and reinstall everything from the scratch.
Possible reasons for the mess is that you have used both sudo easy_install / sudo pip and Linux distribution packages to mix and match system-wide installation packages. You should use virtualenv instead if you use pip/easy_install (no sudo needed)
http://pypi.python.org/pypi/virtualenv
I had a similar problem, but things were working fine as root. In my case, I found that the permissions on the python packages were not readable by the ID I was running the command under.
To correct it, I ran the following command to open the permission for read and execute to all users:
sudo chmod o+rx -R /usr/local/lib/python2.7/dist-packages/*.egg
I had similar issue when trying to install package via pip with python 3.6 on windows. (pip is supposed to work out of the box with this install)
The problem was not running as administrator.
Running cmd as administrator and then installing my package worked:
python -m pip install pylint
I was trying to get pip to work on the 2.7.0 version, but it seems like it doesn't come with the easy_install/pip files (Script folder in main directory), installing 2.7.13 solved the problem for me.