I have an issue with virtualenvwrapper that requires reinstalling pip as the first step, and I am getting a strange complaint about urllib3:
$ python get-pip.py
Traceback (most recent call last):
File "get-pip.py", line 19177, in <module>
main()
File "get-pip.py", line 194, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 82, in bootstrap
import pip
File "/tmp/tmppQTQty/pip.zip/pip/__init__.py", line 16, in <module>
File "/tmp/tmppQTQty/pip.zip/pip/vcs/mercurial.py", line 9, in <module>
File "/tmp/tmppQTQty/pip.zip/pip/download.py", line 39, in <module>
File "/tmp/tmppQTQty/pip.zip/pip/_vendor/requests/__init__.py", line 61, in <module>
File "/tmp/tmppQTQty/pip.zip/pip/_vendor/requests/packages/__init__.py", line 29, in <module>
ImportError: No module named urllib3
when I search the pip file get-pip.py, I don't see any reference to urllib3.
I have python2.6, py2.7, and py3.4 on the machine
cchilders:~/Downloads
$ which python
/usr/local/bin/python
cchilders:~/Downloads
$ which pip
/usr/local/bin/pip
cchilders:/usr/local/bin
$ ls
2to3 easy_install-2.7 ipython pip3 smtpd.py
celery fop ipython2 pip3.5 uncompyle2
celerybeat grunt jsonlint pydoc virtualenv
celeryd idle pbr python virtualenv-clone
celeryd-multi ipdb pip python2.6 virtualenvwrapper_lazy.sh
charm iptest pip2 python2.6-config virtualenvwrapper.sh
easy_install iptest2 pip2.7 python-config
Python is defaulting to 2.6.9 which isn't what I want:
cchilders:/usr/bin
$ python
Python 2.6.9
I do not have anaconda on the machine, which caused someone else's problem. Any advice what to do now appreciated, thank you
Very first you should to know what default python version you are using then, suppose if you are using python2.7 then try to find installed pip packages under that python version using pip freeze or pip freeze | grep -i urllib3
i guess urllib3 is not installed
wget https://pypi.python.org/packages/3b/f0/e763169124e3f5db0926bc3dbfcd580a105f9ca44cf5d8e6c7a803c9f6b5/urllib3-1.16.tar.gz#md5=fcaab1c5385c57deeb7053d3d7d81d59
tar xvf urllib3-1.16.tar.gz && cd urllib3-1.16/
python setup.py install
Related
I installed elastic search curator via the following command.
sudo pip install -U elasticsearch-curator
It all installed OK.
However now when I do the following
curator_cli --version
I get the following dependency warning.
/usr/local/lib/python2.7/dist-packages/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
warnings.warn(warning, RequestsDependencyWarning)
curator_cli, version 5.5.4
How do I either fix the warning or hide it?
So took a couple of things for me to get this working.
First I upgraded cyptography as per Mufeeds suggestion
sudo pip install --upgrade cryptography
This then gave me a new error everytime I did pip <any command>
Traceback (most recent call last):
File "/usr/local/bin/pip", line 7, in <module>
from pip._internal import main
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/__init__.py", line 42, in <module>
from pip._internal import cmdoptions
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cmdoptions.py", line 16, in <module>
from pip._internal.index import (
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/index.py", line 15, in <module>
from pip._vendor import html5lib, requests, six
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py", line 86, in <module>
from pip._vendor.urllib3.contrib import pyopenssl
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/usr/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 118, in <module>
SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'
Resolved this by resintalling PyOpenSSL
sudo python -m easy_install --upgrade pyOpenSSL
Curator is now working as expected without the warnings
curator_cli --version
> curator_cli, version 5.5.4
This 1st step below will update cryptography, but break pyopenssl.
sudo pip install --upgrade cryptography
We can fix that by removing the pyopennssl library and use pip to reinstall.
sudo rm -rf /usr/lib/python2.7/dist-packages/OpenSSL
sudo rm -rf /usr/lib/python2.7/dist-packages/pyOpenSSL-0.15.1.egg-info
sudo pip install pyopenssl --upgrade
sudo pip install cryptography --upgrade
The last line will produce an error if the open sll library were to still be broken, so this validates all should be well...
My preference is to avoid another package manage like easy install in the mix, so sharing this in case that is anyone else's preference as well.
When I try to install any package via pip on MacOS Sierra, I encounter the following error:
File "/usr/local/bin/pip", line 7, in <module>
from pip import main
File "/Library/Python/2.7/site-packages/pip/__init__.py", line 26, in <module>
from pip.utils import get_installed_distributions, get_prog
File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 27, in <module>
from pip._vendor import pkg_resources
File "/Library/Python/2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3018, in <module>
#_call_aside
File "/Library/Python/2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3004, in _call_aside
f(*args, **kwargs)
File "/Library/Python/2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3046, in _initialize_master_working_set
dist.activate(replace=False)
File "/Library/Python/2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2578, in activate
declare_namespace(pkg)
File "/Library/Python/2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2152, in declare_namespace
_handle_ns(packageName, path_item)
File "/Library/Python/2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2091, in _handle_ns
loader.load_module(packageName)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 246, in load_module
mod = imp.load_module(fullname, self.file, self.filename, self.etc)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/PyObjCTools/__init__.py", line 1, in <module>
__import__('pkg_resources').declare_namespace(__name__)
File "/Users/jiaseny/Library/Python/2.7/lib/python/site-packages/pkg_resources/__init__.py", line 72, in <module>
from . import py31compat
ImportError: cannot import name py31compat
Trying sudo pip install pkg_resources, sudo pip install setuptools as suggested in ImportError: No module named py31compat
resulted in the same error.
Perhaps I should try uninstalling and reinstalling pip? But sudo pip uninstall pip and sudo easy_install pip resulted in the same errors...
Based on the path to your python, I can see you're not using the system python which is installed natively, nor are you using homebrew or pyenv, either of which I would highly recommend.
Pyenv is my preferred method of installation for development purposes. A manual install is straight forward and only mildly more difficult than with homebrew, and its one less thing relying on a relatively opaque box to function. The recommended install from the README is just:
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
exec "$SHELL"
pyenv install 2.7.14
pyenv global 2.7.14
Alternatively if you use homebrew you can just brew install pyenv, and I believe it will set everything up for you, before the pyenv install.
Or if all you want is a somewhat more up to date python than the system one, install homebrew and brew install python.
In case you come here through Google, I had similar issue on MacOS. I tried the the accepted answer it did not work. But doing these upgrade resolved it for me:
pip install --upgrade pip
pip install --upgrade setuptools
pip install --upgrade distribute
I'm trying to set up a python 3.6 environment with Django. The installation instructions say I should install mysqlclient to be able to connect to mySQL. I get this:
dennis#django:~$ sudo -H pip3 install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-1.3.10.tar.gz
Complete output from command python setup.py egg_info:
/bin/sh: 1: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-4jiw3hvk/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "/tmp/pip-build-4jiw3hvk/mysqlclient/setup_posix.py", line 44, in get_config
libs = mysql_config("libs_r")
File "/tmp/pip-build-4jiw3hvk/mysqlclient/setup_posix.py", line 26, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
OSError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-4jiw3hvk/mysqlclient/
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
mySQL is properly installed. What should be in the mysql_config file?
When I try to upgrade pip3 I get this:
dennis#django:~$ sudo -H pip3 install --upgrade pip3
Collecting pip3
Could not find a version that satisfies the requirement pip3 (from versions: )
No matching distribution found for pip3
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
After installing mysqlclient with pip3, I noticed that the module was installed in the python3.5 directory instead of in the python3.6 directory so when I tried to import the MySQLdb module running python3.6, it was not found
dennis#django:~/python_db$ python
Python 3.6.0+ (default, Feb 4 2017, 11:11:46)
[GCC 5.4.1 20161202] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'MySQLdb'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
from apport.packaging_impl import impl as packaging
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in <module>
import apt
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
Original exception was:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'MySQLdb'
>>>
I then reran using python 3.5 and it was found. How do I install modules using pip3 into the 3.6 directory?
If you're using Mac OS, try this:
brew install mysql
If you're using Ubuntu14/16, try this:
sudo apt install libmysqlclient-dev
and one more:
pip3 can be updated with sudo pip3 install -U pip
LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient
In my case the issue was solved by doing the following:
sudo aptitude install libmysqlclient-dev
As I was using Python 3.x, the following was also necessary:
sudo aptitude install python3-dev
If you're running MAMP on OSX, do this:
export PATH=$PATH:/Applications/MAMP/Library/bin
In Debian Stretch the required package name seems to have changed to default-libmysqlclient-dev
https://packages.debian.org/stretch/default-libmysqlclient-dev
you can try this to install mysql to a particular python directory, for example w/ python 3.6
sudo python3.6 /usr/bin/pip3 install mysqlclient
Looking over this old question (while looking for something else), I observe that the problem could be that the directory containing mysql_config was not in the current $PATH. Apparently that's what the install script uses to try to find it. It's possible for "mysql to be installed," but not on the $PATH – or for the $PATH to refer to the wrong version.
My Ubuntu 10.04 came with Python 2.6. Now, I also installed Python 2.7, which is the system default now because when I start python from the terminal, it starts python 2.7.
Now, I want to install the library pysftp using pip, but I'm having a hard time doing so. Below follow some results of my attempts and conclusions. I did pip install pysftp, but it says the following:
Downloading/unpacking pysftp
Running setup.py egg_info for package pysftp
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/usr/local/lib/python2.6/dist-packages/setuptools/__init__.py", line 12, in <module>
from setuptools.extension import Extension
File "/usr/local/lib/python2.6/dist-packages/setuptools/extension.py", line 8, in <module>
from .dist import _get_unpatched
File "/usr/local/lib/python2.6/dist-packages/setuptools/dist.py", line 21, in <module>
packaging = pkg_resources.packaging
AttributeError: 'module' object has no attribute 'packaging'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/usr/local/lib/python2.6/dist-packages/setuptools/__init__.py", line 12, in <module>
from setuptools.extension import Extension
File "/usr/local/lib/python2.6/dist-packages/setuptools/extension.py", line 8, in <module>
from .dist import _get_unpatched
File "/usr/local/lib/python2.6/dist-packages/setuptools/dist.py", line 21, in <module>
packaging = pkg_resources.packaging
AttributeError: 'module' object has no attribute 'packaging'
----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in ./pip-log.txt
It seems to me that pip (which was obviously installed before Python 2.7 was installed) links to the old version of Python, which doesn't support pysftp. Also because when I do pip --version it says:
pip 0.3.1 from /usr/lib/python2.6/dist-packages (python 2.6)
When I do whereis python, it gives me the following information:
python: /usr/src/Python-2.7.10/python /usr/bin/python2.6 /usr/bin/python /etc/python2.6 /etc/python /usr/lib/python2.6 /usr/lib/python3.1 /usr/lib64/python2.6 /usr/lib64/python3.1 /usr/local/bin/python2.7-config /usr/local/bin/python /usr/local/bin/python2.7 /usr/local/lib/python2.6 /usr/local/lib/python2.7 /usr/include/python2.6 /usr/share/python /usr/share/man/man1/python.1.gz
How can I install pysftp?
You need to reinstall pip for Python 2.7, then run pip2.7 install pysftp. You need a pip installation for each version of Python you want to use it with. The setuptools package is probably the easiest way to get going; you can simply run the following to do it all in one fell swoop:
wget https://bootstrap.pypa.io/ez_setup.py -O --no-check-certificate - | sudo python2.7 && sudo easy_install-2.7 pip && sudo pip2.7 install pysftp
Sometimes older Linux installs have issues with the above command, due to an "invalid" certificate encounted while downloading the full setuptools package via ez_setup.py (see here for more details). This can be circumvented with this alternative one-fell-swoop command:
wget https://pypi.python.org/packages/source/s/setuptools/setuptools-18.8.1.zip --no-check-certificate && unzip setuptools-18.8.1.zip && cd setuptools-18.8.1 && sudo python setup.py install && sudo easy_install-2.7 pip && sudo pip2.7 install pysftp
I think you need to install some sort of 'essentials package' using the code
sudo apt-get install build-essential libssl-dev libffi-dev python-dev
Then you can install :
sudo pip install pysftp
sudo pip install enum
Today,I have installed the ipython by the follow steps:
cd
sudo apt-get install git
git clone https://github.com/ipython/ipython.git
cd ipython
sudo python setup.py install
But I meet a error when I open the ipython:
~$ ipython
Traceback (most recent call last):
File "/usr/local/bin/ipython", line 4, in <module>
from IPython import start_ipython
File "/usr/local/lib/python2.7/dist-packages/IPython/__init__.py", line 48, in <module>
from .terminal.embed import embed
File "/usr/local/lib/python2.7/dist-packages/IPython/terminal/embed.py", line 16, in <module>
from IPython.core.interactiveshell import DummyMod
File "/usr/local/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 31, in <module>
from pickleshare import PickleShareDB
ImportError: No module named pickleshare
How to deal with the error?
I solved the problem with sudo easy_install pickleshare
(https://pypi.python.org/pypi/pickleshare/0.3)
It looks that pickleshare is in package IPython.utils.
Use this pip install -I path.py==7.7.1
Updating the package to version 8.1 should fix the problem as well now:
pip install -I path.py==8.1