I am confused on python on its installation path and configuration.
I know pip this command for installation or listing the modules.
The example is like pip freeze. It will show up the list of module.
Recently, I got an error when I execute pip. I had python2 and python3 on the system without any virtualenv. I use ls /usr/bin/python* -al | awk {print $9 $10 $11} to know python commands and ls /usr/bin/pip* -al to know the pip commands.
python->python2.7
python2->python2.7
python2.7
python2.7-config->arm-linux-gnueabihf-python2.7-config
python2-config->python2.7-config
python3->python3.4
python3.4
python3.4m
python3m->python3.4m
python-config->python2.7-config
pip pip2 pip3
In addition, I use ls on /usr/local/bin and know the pip commands.
pip pip2 pip2.7 pip3 pip3.4 pip3.5
The error message is this when I execute pip.
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 11, in <module>
load_entry_point('pip==9.0.1', 'console_scripts', 'pip3')()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 572, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2752, in load_entry_point
return ep.load()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2405, in load
return self.resolve()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2411, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/local/lib/python2.7/dist-packages/pip/__init__.py", line 76, in <module>
from pip.commands import commands, get_summaries, get_similar_commands
File "/usr/local/lib/python2.7/dist-packages/pip/commands/__init__.py", line 6, in <module>
from pip.commands.bundle import BundleCommand
File "/usr/local/lib/python2.7/dist-packages/pip/commands/bundle.py", line 6, in <module>
from pip.commands.install import InstallCommand
File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 5, in <module>
from pip.req import InstallRequirement, RequirementSet, parse_requirements
File "/usr/local/lib/python2.7/dist-packages/pip/req/__init__.py", line 3, in <module>
from .req_install import InstallRequirement
File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 42, in <module>
from pip.utils.hashes import Hashes
File "/usr/local/lib/python2.7/dist-packages/pip/utils/hashes.py", line 5, in <module>
from pip.exceptions import HashMismatch, HashMissing, InstallationError
ImportError: cannot import name HashMissing`
How to resolve this error? Why does the system show up the error?
The result is the conflict without a specific command.
Use python2.7 -m pip or python2 -m pip for a specific command. Vice versa, on python3, use python3 -m pip or python3.4 -m pip for a specific command.
In addition, use python or python3 to get into interactive mode. Then, use import sys and sys.path to get the path of python package.
Related
I tried to install from pip and keep on getting similar type of errors.
$ pip install quandl
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 558, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2682, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2355, in load
return self.resolve()
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2361, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 74, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 22, in <module>
import requests, six
File "/usr/lib/python2.7/dist-packages/requests/__init__.py", line 53, in <module>
from .packages.urllib3.contrib import pyopenssl
File "/usr/lib/python2.7/dist-packages/urllib3/contrib/pyopenssl.py", line 53, in <module>
import OpenSSL.SSL
File "/home/ubuntu/.local/lib/python2.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/home/ubuntu/.local/lib/python2.7/site-packages/OpenSSL/SSL.py", line 112, in <module>
if _lib.Cryptography_HAS_SSL_ST:
AttributeError: 'module' object has no attribute 'Cryptography_HAS_SSL_ST'
Now even though i tried to install different pip modules iam getting same error.Is there any solution for this ? This was caused due to the unexpected killing of the process while a pip module is being downloaded.
Please help me with the necessary steps to rectify this error.
I tried to install this
$ pip install -U cryptography
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 558, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2682, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2355, in load
return self.resolve()
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2361, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 74, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 22, in <module>
import requests, six
File "/usr/lib/python2.7/dist-packages/requests/__init__.py", line 53, in <module>
from .packages.urllib3.contrib import pyopenssl
File "/usr/lib/python2.7/dist-packages/urllib3/contrib/pyopenssl.py", line 53, in <module>
import OpenSSL.SSL
File "/home/ubuntu/.local/lib/python2.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/home/ubuntu/.local/lib/python2.7/site-packages/OpenSSL/SSL.py", line 112, in <module>
if _lib.Cryptography_HAS_SSL_ST:
AttributeError: 'module' object has no attribute 'Cryptography_HAS_SSL_ST'
Ubuntu 16.04.3 here:
I think I have fixed this by removing the python-openssl package (and it's dependencies) with:
apt-get --auto-remove remove python-openssl
Then installing the latest version with pip:
pip install pyOpenSSL
Of course, if you install another apt package that depends on it, it'll pull it back in. I hope if you use pip for everything you can from now on instead of apt, it should be fine.
Edit: as of January 2019 this issue doesn't seem to exist any more.
I was able to resolve this by deleting the openssl python lib and reinstalling (purge before install did not work):
$ sudo rm -rf /usr/local/lib/python2.7/dist-packages/OpenSSL/
$ sudo apt install --reinstall python-openssl
If even pip is not working then try following:
sudo easy_install -U cffi
sudo easy_install -U cryptography
It works for me.
To fix it on RHEL/CentOS:
sudo rm -rf /usr/lib/python2.7/site-packages/OpenSSL/
sudo yum install pyOpenSSL
This did it for me on CentOS 7. Cheers!
I got this error and solved it by doing these steps (don't forget to put your own username):
rm -rf /home/<Your Username>/.local/lib/python2.7/site-packages/OpenSSL
sudo rm -rf usr/local/lib/python2.7/dist-packages/OpenSSL/
pip install pyOpenSSL
Try to do the following:
$ rm -rf /home/ubuntu/.local/lib/python2.7/site-packages/OpenSSL
$ rm -rf /home/ubuntu/.local/lib/python2.7/site-packages/pyOpenSSL-0.15.1.egg-info
In the last line, you might have another version of pyOpenSSL, specify yours.
Quick Fix
Move the OpenSSL folder to OpenSSLBAK (for instance) to avoid the error
# cd /usr/lib/python2.7/dist-packages
# mv OpenSSL OpenSSLBAK
It should be good
Try reinstalling python of which will fix many of your problems,do
sudo apt-get install --reinstall python2.7
and pip will be missing after reinstalling,do
sudo apt-get install python-pip
Try to download the suitable wheel file from here depending in your operating system and python version. Then add this file to Python/Scripts and use the code below to install it.
pip install nameofwheelfile.whl
The wheel file contains all the dependencies.
I am having real trouble trying to use pip to install pyserial for python 3.5.2, I am trying to install pip using 'sudo easy_install pip'.
I keep getting this error message:
sudo easy_install pip
Traceback (most recent call last):
File "/usr/local/bin/easy_install", line 11, in <module>
load_entry_point('setuptools==29.0.1', 'console_scripts', 'easy_install')()
File"/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 565, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File"/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2697, in load_entry_point
return ep.load()
File"/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2370, in load
return self.resolve()
File"/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2376, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "build/bdist.macosx-10.12-intel/egg/setuptools/__init__.py", line 10, in <module>
File "build/bdist.macosx-10.12 intel/egg/setuptools/extern/__init__.py", line 1, in <module>
ImportError: No module named extern
Any Help would be appreciated.
Running sudo easy_install pip will install pip for Python 2, which you don't want if you're using Python 3.
You might have pip installed for Python 3 already (run which pip3 to check). If so, you can install pyserial using pip3
pip3 install pyserial
However, it would be better to use a virtual environment. See the hitchhiker's guide to Python to get started.
It is a tough situation I am dealing with. Here is short version of my problem:
I am working on Ubuntu 12.04
I would like to install Python 3.5.x with openCV library. I would also like to use pip3 for managing package installation of python.
Here is how the version of my pythons looks like
$ python --version
Python 2.7.3
$ python3 --version
Python 3.5.2
So far it looks I have achieved my goal.
When I use virtualenv to manage python3 libraries:
virtualenv -p /usr/bin/python3 py3env
source py3env/bin/activate
I see the version of my python as follows:
(py3env)yxxxxa#yxxxxa-Precision-M4800:~$ python3 --version
Python 3.2.3
I seems there is another version of python in my machine 3.2.3 messing up with the version 3.5.2 that I have installed. This is my first problem.
The second related problem is that I am unable to install pip 3. There is this error I receive due to the same python version conflict:
$ pip
/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/_vendor /pkg_resources/__init__.py:80: UserWarning: Support for Python 3.0-3.2 has been dropped. Future versions will fail here.
warnings.warn(msg)
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==8.1.2', 'console_scripts', 'pip')()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 337, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2280, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1990, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/__init__.py", line 16, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/download.py", line 36, in <module>
from pip.utils.ui import DownloadProgressBar, DownloadProgressSpinner
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/utils/ui.py", line 15, in <module>
from pip._vendor.progress.bar import Bar, IncrementalBar
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/_vendor/progress/bar.py", line 48
empty_fill = u'∙'
^
SyntaxError: invalid syntax
yasharatena#yasharatena-Precision-M4800:~$ pip3
/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/_vendor/pkg_resources/__init__.py:80: UserWarning: Support for Python 3.0-3.2 has been dropped. Future versions will fail here.
warnings.warn(msg)
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 9, in <module>
load_entry_point('pip==8.1.2', 'console_scripts', 'pip3')()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 337, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2280, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1990, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/__init__.py", line 16, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/download.py", line 36, in <module>
from pip.utils.ui import DownloadProgressBar, DownloadProgressSpinner
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/utils/ui.py", line 15, in <module>
from pip._vendor.progress.bar import Bar, IncrementalBar
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/_vendor/progress/bar.py", line 48
empty_fill = u'∙'
^
SyntaxError: invalid syntax
What are your expert opinions about the stated problem? Any cool idea to handle this? Thanks alot in advance
This solved my first problem. Now the second problem aslo remains, how
can I install pip3 under python 3.5.2 (preferably using viretualenv) ?
Here is answer:
python3 -m virtualenv py3env
source py3env/bin/activate
Python 3.5 should have pip by default, also after above commands You can use pip:)
For example :
python -m pip install requests
EDIT:
Here You could find very good explainations if You still need install pip after create virtualenv.
Whenever I try to install anything using pip I get the following error:
$ sudo pip install --upgrade pip
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==7.0.3', 'console_scripts', 'pip')()
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 558, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2682, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2355, in load
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2361, in resolve
File "/usr/local/lib/python2.7/site-packages/pip-7.0.3-py2.7.egg/pip/__init__.py", line 15, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/lib/python2.7/site-packages/pip-7.0.3-py2.7.egg/pip/vcs/subversion.py", line 9, in <module>
from pip.index import Link
File "/usr/local/lib/python2.7/site-packages/pip-7.0.3-py2.7.egg/pip/index.py", line 30, in <module>
from pip.wheel import Wheel, wheel_ext
File "/usr/local/lib/python2.7/site-packages/pip-7.0.3-py2.7.egg/pip/wheel.py", line 35, in <module>
from pip._vendor.distlib.scripts import ScriptMaker
File "/usr/local/lib/python2.7/site-packages/pip-7.0.3-py2.7.egg/pip/_vendor/__init__.py", line 92, in load_module
raise ImportError("No module named '%s'" % (name,))
ImportError: No module named 'pip._vendor.distlib.scripts'
This also happens when I try to upgrade pip, install sphinx or basically any install/upgrade option using pip.
I am running Ubuntu 15.10 and using Python 2.7.10
StackOverflow has said this is a duplicate, and that there is a solution at ImportError: No module named 'pip._vendor.distlib.scripts' when I try to install fabric by python pip however the recommend solution on this post is not actually a soltuion. It does not solve my issue, nor does it appear to solve the original posters problem.
Try this:
sudo pip install --upgrade --no-use-wheel pip
I first installed distribute, then pip with easy_install but when I run:
sudo pip install virtualenv
I get these error messages:
Traceback (most recent call last):
File "/usr/bin/pip", line 8, in ? sys.exit(
File "/usr/lib/python2.4/site-packages/distribute-0.6.49-py2.4.egg/pkg_resources.py", line 345, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.4/site-packages/distribute-0.6.49-py2.4.egg/pkg_resources.py", line 2381, in load_entry_point
return ep.load()
File "/usr/lib/python2.4/site-packages/distribute-0.6.49-py2.4.egg/pkg_resources.py", line 2087, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.4/site-packages/pip-1.4-py2.4.egg/pip/__init__.py", line 10, in ?
from pip.util import get_installed_distributions, get_prog
File "/usr/lib/python2.4/site-packages/pip-1.4-py2.4.egg/pip/util.py", line 17, in ?
from pip.vendor.distlib import version
File "/usr/lib/python2.4/site-packages/pip-1.4-py2.4.egg/pip/vendor/__init__.py", line 8
from __future__ import absolute_importSyntaxError: from __future__ imports must occur at the beginning of the file
I do not know what to do to install virtualenv properly now?
You appear to be using Python 2.4 - try creating the virtualenv with a version of Python which includes from __future__ import absolute_import (Python 2.5 or later).
You can specify which Python to use like this:
virtualenv -p /usr/bin/python2.7