Unable to install MySQL-python - django

Okay I recently upgraded from Ubuntu 10.04 to 12.04
Only to be faced by a lot of problems. I am a newbie at this so you might have to tell me in a little more detail or step-by-step
I had a django project that was working perfectly but now it gives me this error :
File "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 16, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory
or in python :
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.linux-i686/egg/MySQLdb/__init__.py", line 19, in <module>
File "build/bdist.linux-i686/egg/_mysql.py", line 7, in <module>
File "build/bdist.linux-i686/egg/_mysql.py", line 6, in __bootstrap__
ImportError: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory
Anyways I thought there was some problem with my MySQL-python so I tried re-installing it.
sudo pip install mysql-python
gives :
Downloading/unpacking mysql-python
Running setup.py egg_info for package mysql-python
The required version of distribute (>=0.6.28) is not available,
and can't be installed while this script is running. Please
install a more recent version first, using
'easy_install -U distribute'.
(Currently using distribute 0.6.24dev-r0 (/usr/lib/python2.7/dist-packages))
Complete output from command python setup.py egg_info:
The required version of distribute (>=0.6.28) is not available,
and can't be installed while this script is running. Please
install a more recent version first, using
'easy_install -U distribute'.
(Currently using distribute 0.6.24dev-r0 (/usr/lib/python2.7/dist-packages))
----------------------------------------
Command python setup.py egg_info failed with error code 2 in /tmp/pip-build/mysql-python
Storing complete log in /home/nabeel/.pip/pip.log
If I do :
sudo easy_install -U distribute
It gives this error :
Searching for distribute
Reading http://pypi.python.org/simple/distribute/
Reading http://packages.python.org/distribute
Best match: distribute 0.6.29
Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.29.tar.gz#md5=1aad767bfca8bebaccafee25f85696cf
Processing distribute-0.6.29.tar.gz
Running distribute-0.6.29/setup.py -q bdist_egg --dist-dir /tmp/easy_install-K8ZuMX/distribute-0.6.29/egg-dist-tmp-Fj0gj_
Before install bootstrap.
Scanning installed packages
Setuptools installation detected at /usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
Egg installation
Patching...
Renaming /usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg to /usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg.OLD.1350776909.4
Patching complete.
Relaunching...
Traceback (most recent call last):
File "/usr/local/bin/easy_install", line 9, in <module>
load_entry_point('distribute==0.6.8', 'console_scripts', 'easy_install')()
File "/usr/local/lib/python2.7/site-packages/distribute-0.6.8-py2.7.egg/setuptools/command/easy_install.py", line 1708, in main
with_ei_usage(lambda:
File "/usr/local/lib/python2.7/site-packages/distribute-0.6.8-py2.7.egg/setuptools/command/easy_install.py", line 1696, in with_ei_usage
return f()
File "/usr/local/lib/python2.7/site-packages/distribute-0.6.8-py2.7.egg/setuptools/command/easy_install.py", line 1712, in <lambda>
distclass=DistributionWithoutHelpCommands, **kw
File "/usr/local/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/local/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/local/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/local/lib/python2.7/site-packages/distribute-0.6.8-py2.7.egg/setuptools/command/easy_install.py", line 236, in run
self.easy_install(spec, not self.no_deps)
File "/usr/local/lib/python2.7/site-packages/distribute-0.6.8-py2.7.egg/setuptools/command/easy_install.py", line 471, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/usr/local/lib/python2.7/site-packages/distribute-0.6.8-py2.7.egg/setuptools/command/easy_install.py", line 501, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/usr/local/lib/python2.7/site-packages/distribute-0.6.8-py2.7.egg/setuptools/command/easy_install.py", line 680, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/usr/local/lib/python2.7/site-packages/distribute-0.6.8-py2.7.egg/setuptools/command/easy_install.py", line 957, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/usr/local/lib/python2.7/site-packages/distribute-0.6.8-py2.7.egg/setuptools/command/easy_install.py", line 946, in run_setup
run_setup(setup_script, args)
File "/usr/local/lib/python2.7/site-packages/distribute-0.6.8-py2.7.egg/setuptools/sandbox.py", line 29, in run_setup
lambda: execfile(
File "/usr/local/lib/python2.7/site-packages/distribute-0.6.8-py2.7.egg/setuptools/sandbox.py", line 70, in run
return func()
File "/usr/local/lib/python2.7/site-packages/distribute-0.6.8-py2.7.egg/setuptools/sandbox.py", line 31, in <lambda>
{'__file__':setup_script, '__name__':'__main__'}
File "setup.py", line 131, in <module>
File "/tmp/easy_install-K8ZuMX/distribute-0.6.29/distribute_setup.py", line 368, in _before_install
File "/tmp/easy_install-K8ZuMX/distribute-0.6.29/distribute_setup.py", line 441, in _fake_setuptools
File "/tmp/easy_install-K8ZuMX/distribute-0.6.29/distribute_setup.py", line 450, in _relaunch
NameError: global name '_cmd1' is not defined
Again now I have gone to this link :
http://pypi.python.org/pypi/setuptools/0.6c11
to download and install setuptools..
I have also installed the latest distribute 0.6.8 from here :
http://pypi.python.org/pypi/distribute/0.6.8
I have also tried uninstalling the previous versions and installing back but it doesn't seems to work.
I have got Python 2.7.3 installed
Could someone please explain to me what is going on... How I can install Mysqldb...
I have also ran these commands on shell :
sudo apt-get install mysql-server mysql-client python-mysqldb libmysqlclient-dev python-dev
But it didn't help ...
UPDATE I JUST DID THIS AND GOT THIS ERROR :
nabeel#nabeel-pc:~$ pip uninstall setuptools
Uninstalling distribute:
/usr/bin/easy_install
/usr/bin/easy_install-2.7
/usr/lib/python2.7/dist-packages/distribute-0.6.24dev_r0.egg-info
/usr/lib/python2.7/dist-packages/easy_install.pyc
/usr/lib/python2.7/dist-packages/pkg_resources.pyc
/usr/lib/python2.7/dist-packages/setuptools
/usr/lib/python2.7/dist-packages/site.pyc
/usr/share/pyshared/easy_install.py
/usr/share/pyshared/pkg_resources.py
/usr/share/pyshared/site.py
Proceed (y/n)? y
Successfully uninstalled distribute
nabeel#nabeel-pc:~$ sudo easy_install -U distribute
Searching for distribute
Reading http://pypi.python.org/simple/distribute/
Reading http://packages.python.org/distribute
Best match: distribute 0.6.29
Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.29.tar.gz#md5=1aad767bfca8bebaccafee25f85696cf
Processing distribute-0.6.29.tar.gz
Running distribute-0.6.29/setup.py -q bdist_egg --dist-dir /tmp/easy_install-Xcer8d/distribute-0.6.29/egg-dist-tmp-K0E7gP
Before install bootstrap.
Scanning installed packages
Setuptools installation detected at /usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
Egg installation
Already patched.
After install bootstrap.
Creating /usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info
Creating /usr/local/lib/python2.7/site-packages/setuptools.pth
Removing distribute 0.6.8 from easy-install.pth file
Adding distribute 0.6.29 to easy-install.pth file
Installing easy_install script to /usr/local/bin
Installing easy_install-2.7 script to /usr/local/bin
Installed /usr/local/lib/python2.7/site-packages/distribute-0.6.29-py2.7.egg
Processing dependencies for distribute
Finished processing dependencies for distribute
nabeel#nabeel-pc:~$ sudo pip install mysql-python
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
UPDATE 2 :
I have managed to install virtualenv
now in the environment I have also managed to install MySQLdb.
Here's theh error I get while running my server :
sudo python manage.py syncdb
I get this error:
File "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 16, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory
(myenv)nabeel#nabeel-pc:~/workspace/gteam/metrics$ python
Python 2.7.3 (default, Oct 6 2012, 21:57:36)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>> exit()

Using virtualenv
First things first. Make sure you have Mysql, Setuptools and some essentials:
sudo apt-get install mysql-server
sudo apt-get install python-setuptools python-dev build-essential
Now install VirtualEnv:
sudo easy_install -U virtualenv
Create a Virtual Environment. As the documentation says: virtualenv is a tool to create isolated Python environments. This means that the chances of getting a conflict are really small. Here "myenv" is the name of a folder where you can access your environment, so create it where you want.
virtualenv --distribute myenv
Then go to "myenv" directory and run this to activate it:
source myenv/bin/activate
You need to install libmysqlclient-dev to get MySQL-python working:
sudo apt-get install libmysqlclient-dev
Now you're ready to install MySQL-python:
pip install MySQL-python
and everything should be working.
When you don't want to work in that environment anymore, write in the terminal:
deactivate
UPDATE:
Since this answer keeps getting upvotes, let me show you how to do the same using conda, which has become my favorite environment nowadays. First you have to install anaconda (I believe you can also install miniconda, which is a lighter version that includes conda and some packages.) Here you will find the installer for Linux, OS X and Windows. It is a big file but contains a lot of pre-compiled packages ready to be installed. Assuming you already have installed anaconda, you can simply run:
conda create -n mysql-env python
mysql-env is the name of the environment (you can call it whatever you want) and python is the default version of python to be installed (currently, 2.7.10). Alternatively, install other version of python with conda create -n my-new-env python=3.4.
Then you activate your environment:
source activate mysql-env
and finally install mysql-python:
conda install MySQL-python
(I think conda install mysql-python also works)
And that's all.

easy_install -U distribute solved my problem

In some Ubuntu installations, you'll also want to consider libmysqlclient-dev:
sudo apt-get install python-dev libmysqlclient-dev
It also held me back. The other responders probably already had it installed and didn't realize it was required.

Related

/bin/sh: mysql_config: not found while making docker image in django app [duplicate]

This is the error I get
(mysite)zjm1126#zjm1126-G41MT-S2:~/zjm_test/mysite$ pip install mysql-python
Downloading/unpacking mysql-python
Downloading MySQL-python-1.2.3.tar.gz (70Kb): 70Kb downloaded
Running setup.py egg_info for package mysql-python
sh: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/home/zjm1126/zjm_test/mysite/build/mysql-python/setup.py", line 15, in <module>
metadata, options = get_config()
File "setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "setup_posix.py", line 24, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
Complete output from command python setup.py egg_info:
sh: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/home/zjm1126/zjm_test/mysite/build/mysql-python/setup.py", line 15, in <module>
metadata, options = get_config()
File "setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "setup_posix.py", line 24, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /home/zjm1126/.pip/pip.log
(mysite)zjm1126#zjm1126-G41MT-S2:~/zjm_test/mysite$ pip install mysql-python
Downloading/unpacking mysql-python
Running setup.py egg_info for package mysql-python
sh: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/home/zjm1126/zjm_test/mysite/build/mysql-python/setup.py", line 15, in <module>
metadata, options = get_config()
File "setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "setup_posix.py", line 24, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
Complete output from command python setup.py egg_info:
sh: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/home/zjm1126/zjm_test/mysite/build/mysql-python/setup.py", line 15, in <module>
metadata, options = get_config()
File "setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "setup_posix.py", line 24, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /home/zjm1126/.pip/pip.log
What can I do to resolve this?
It seems mysql_config is missing on your system or the installer could not find it.
Be sure mysql_config is really installed.
For example on Debian/Ubuntu you must install the package:
sudo apt-get install libmysqlclient-dev
Maybe the mysql_config is not in your path, it will be the case when you compile by yourself
the mysql suite.
Update: For recent versions of debian/ubuntu (as of 2018) it is
sudo apt install default-libmysqlclient-dev
In Mac OS, I simply ran this in terminal to fix:
export PATH=$PATH:/usr/local/mysql/bin
This is the quickest fix I found - it adds it to the path, but I think you're better off adding it permanently (ie add it to /etc/paths) if you plan to install MySQL-python in another environment.
(tested in OSX Mountain Lion)
There maybe various answers for the above issue, below is a aggregated solution.
For Ubuntu:
$ sudo apt update
$ sudo apt install python-dev
$ sudo apt install python-MySQLdb
For CentOS:
$ yum install python-devel mysql-devel
apt-get install libmysqlclient-dev python-dev
Seemed to do the trick.
If you are on MAC
Install this globally
brew install mysql
then export path like this
export PATH=$PATH:/usr/local/mysql/bin
Than globally or in your venv whatever you like
pip install MySQL-Python
Note: globally for python3 as Mac can have both python2 & 3
pip3 install MySQL-Python
You can use the MySQL Connector/Python
Installation via PyPip
pip install mysql-connector-python
Further information can be found on the MySQL Connector/Python 1.0.5 beta announcement blog.
On Launchpad there's a good example of how to add-, edit- or remove data with the library.
For centos users:
yum install -y mysql-devel python-devel python-setuptools
then
pip install MySQL-python
If this solution doesn't work, and print gcc compile error like:
_mysql.c:29:20: error: Python.h: No such file or directory
You need to specify the path of Python.h, like this:
pip install --global-option=build_ext --global-option="-I/usr/include/python2.6" MySQL-python
I was trying to install mysql-python on an Amazon EC2 Linux instance and I had to install these :
yum install mysql mysql-devel mysql-common mysql-libs gcc
But then I got this error :
_mysql.c:29:20: fatal error: Python.h: No such file or directory
So I installed :
yum install python-devel
And that did the trick.
For anyone that is using MariaDB instead of MySQL, the solution is to install the libmariadbclient-dev package and create a symbolic link to the config file with the correct name.
For example this worked for me:
ln -s /usr/bin/mariadb_config /usr/bin/mysql_config
For Linux
this works for me
yum install python-devel mysql-devel
Try sudo apt-get build-dep python-mysqldb
OSX Mavericks
Due to changes within osx mavericks & xcode development tools you may get the error on installation
clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
therefore use :
sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install mysql-python
for mariadb install libmariadbclient-dev instead of libmysqlclient-dev
sudo apt-get install libmariadbclient-dev
You should install the mysql first:
yum install python-devel mysql-community-devel -y
Then you can install mysqlclient:
pip install mysqlclient
I had the same problem in the Terraform:light container. It is based on Alpine.
There you have to install mariadb-dev with:
apk add mariadb-dev
But that one is not enough because also all the other dependencies are missed:
apk add python2 py2-pip gcc python2-dev musl-dev
sometimes the error depends on the actual cause. we had a case where mysql-python was installed through the python-mysqldb debian package.
a developer who didn't know this, accidentally ran pip uninstall mysql-python and then failed to recover with pip install mysql-python giving the above error.
pip uninstall mysql-python had destroyed the debian package contents, and of course pip install mysql-python failed because the debian package didn't need any dev files.
the correct solution in that case was apt-get install --reinstall python-mysqldb which restored mysql-python to its original state.
Sequence to be followed.
pip install mysqlclient
sudo apt-get install python3-dev libmysqlclient-dev
pip install configparser
sudo cp /usr/lib/python3.6/configparser.py /usr/lib/python3.6/ConfigParser.py
Then try to install the MYSQL-python again. That Worked for me
On Mac:
brew install mysql-client
locate mysql
mdfind mysql | grep bin
then add to path
export PATH=$PATH:/usr/local/Cellar/mysql-client/8.0.23/bin/
or permanently
echo "export PATH=$PATH:/usr/local/Cellar/mysql-client/8.0.23/bin/" >> ~/.zshrc
source ~/.zshrc
Had a similar issue trying to install on OS X Server 10.6.8. Here's what I had to do.
Using:
MySQL-python 1.2.4b4 (source)
MySQL-5.6.19 (binary installer)
Python 2.7 (binary installer)
NOTE: Installing in virtualenv...
Unzip source, open 'distribute_setup.py' and edit DEFAULT_VERSION to use the latest version of distribute tools, like so:
DEFAULT_VERSION = "0.6.49"
Save. Open 'site.cfg' file and uncomment the path to mysql_config so it looks something like (reference your own path to mysql_config):
# The path to mysql_config.
# Only use this if mysql_config is not on your PATH, or you have some weird
# setup that requires it.
mysql_config = /usr/local/mysql/bin/mysql_config
Now clean, build and make will not fail with the 'mysql_config' not found error.
Hope this helps someone else trying to make use of their old xserves :-)
Your sudo path does not know about your local path... go into superuser mode, add the path, and install it from there.
sudo su
export PATH=$PATH:/usr/local/mysql/bin/
pip install mysql-python
exit
And you're up and running on OSX. Now you have an updated global python.
if you install MySQL-python in your virtual env, you should check the pip version, if the version is older than 9.0.1, please update it
pip install --upgrade pip
write on 27 Aug, 2021
my macos version is BigSur(14.4), and mysql version is mysql8. It seems like in the higher version of mysql, they delete the my_config.h files but change to the mysql.h.
so your guys should run the following shell:
cd /usr/local/include/mysql
cp mysql.h my_config.h
after that, run pip install MySQL-python and everything will be ok.
on MacOS Mojave, mysql_config is found at /usr/local/bin/ rather than /usr/local/mysql/bin as pointed above, so no need to add anything to path.
In my case my database is running on container and my flask app is running on another container when i tried updating code app got broke with error
Complete output from command python setup.py egg_info:
/bin/sh: 1: mysql_config: not found
/bin/sh: 1: mariadb_config: not found
/bin/sh: 1: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-bya8e734/mysqlclient/setup.py", line 15, in <module>
metadata, options = get_config()
File "/tmp/pip-build-bya8e734/mysqlclient/setup_posix.py", line 65, in get_config
libs = mysql_config("libs")
File "/tmp/pip-build-bya8e734/mysqlclient/setup_posix.py", line 31, in mysql_config
raise OSError("{} not found".format(_mysql_config_path))
OSError: mysql_config not found
Key in stack trace is
/bin/sh: 1: mysql_config: not found
because where my flask app is running doesn't have mysql client properly configured so first i installed mysql server and then install
sudo apt-get install mysql-server-5.7 -y
Then started MySQL
mansoor#LARC-mansur:~/Documents/clients/HR/DevopsSimulator/web$ sudo systemctl start mysql
Then install flask-mysql package and this time it worked
mansoor#LARC-mansur:~/Documents/clients/HR/DevopsSimulator/web$ sudo pip3 install flask-mysqldb
This is different case but posting here because may be someone else in the world facing same issue

Unable to install any Python library in VS 2017: 'module' object has no attribute 'main' [duplicate]

I'm facing a problem with Package Installation, pip.
I am using Python 3.6.
When I try to install a package with pip I receive the following message in the cmd.
*C:\Python36\Scripts>pip intstall --user httpie
Traceback (most recent call last):
File "c:\python36\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\python36\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Python36\Scripts\pip.exe\__main__.py", line 5, in <module>
ImportError: cannot import name 'main'*
It happened when I upgraded the pip, before it worked. I tried to uninstal the Python and installed this again but it does not work. I cannot find the solution, any ideas?
Firstly if you have installed pip then remove it by deleting the folder of pip inside python directory. Then install pip by this command:
$ sudo easy_install pip
This will install older version, you can download newer version after 10th when it will come.
I fixed it. I deleted the folder with pip as you said. Because I work in Windows 10, I downloaded the get-pip.py from https://pip.pypa.io/en/stable/installing/ and I run it.
You can also downgrade to pip 9.x using
python -m pip install -U "pip<10"

Ipython broke: doesn't start, says missing 'pathlib2' distribution

When i execute ipython in terminal i see following error
aman#ebex-MacBookPro:~/ipython_work$ ipython
Traceback (most recent call last):
File "/usr/local/bin/ipython", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3141, in <module>
#_call_aside
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3127, in _call_aside
f(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3154, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 640, in _build_master
ws.require(__requires__)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 941, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 828, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pathlib2' distribution was not found and is required by ipython
Just before that i followed
$ git clone --recursive https://github.com/ipython/ipython.git
$ cd ipython
$ pip install -e ".[notebook]"
From the link [How to autosave ipython notebook]
http://stackoverflow.com/questions/21517296/how-to-autosave-ipython-notebook
I tried to uninstall and install using apt-get but its still not working and throwing missing distribution error.
I installed pathlib2 though
sudo pip install pathlib2
But again while accessing ipython
I see another error
pkg_resources.DistributionNotFound: The 'backports.shutil_get_terminal_size' distribution was not found and is required by ipython
You need install some packages manually as follows:
pip install pathlib2
pip install backports.shutil_get_terminal_size
pip install enum34
For me, I also had to pip install enum34 but otherwise int32bit's answer worked.
pip install pathlib2 backports.shutil_get_terminal_size enum34
I see the same error When i execute ipython interminal. The problem was solved by installing libraries about the exception.
I launched the Jupyter notebook from Anaconda "Environments" and the dos Windows open with all the launching packages in issues appearing.
Then I just had to install packages missing and mentioned in this window in your environment one by one. You can retry the same process as many times as needed.

Python Virtualenv not working since upgrading to OS X Mountain Lion

I just updated my OS X from 10.7 to 10.8 (moutain lion).
When I try to run virtualenv venv --distribute
I get this error
File "/usr/local/bin/virtualenv", 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: virtualenv==1.8.2
When I run which python I get /usr/bin/python
When I run which virtualenv I get /usr/local/bin/virtualenv
It seems like the path has changed with the upgrade and does someone knows how to fix it?
Thank you
I was able to solve this by uninstalling virtualenv and then reinstalling virtualenv.
Uninstall
sudo pip uninstall virtualenv
Install
sudo pip install virtualenv

Why am I getting a DistributionNotFound error after attempting to upgrade pip?

Running yolk -U recently I noticed that pip needed upgrading from 1.2.1 to 1.4.1 and dutifully attempted to upgrade it with
pip install --upgrade pip
Though running yolk -U again appeared to confirm a successful upgrade (pip is no longer listed as being out of date), this generated an error message
Downloading/unpacking pip from https://pypi.python.org/packages/source/p/pip/pip-1.4.1.tar.gz#md5=6afbb46aeb48abac658d4df742bff714
Downloading pip-1.4.1.tar.gz (445kB): 445kB downloaded
Running setup.py egg_info for package pip
warning: no files found matching '*.html' under directory 'docs'
warning: no previously-included files matching '*.rst' found under directory 'docs/_build'
no previously-included directories found matching 'docs/_build/_sources'
Installing collected packages: pip
Found existing installation: pip 1.2.1
Uninstalling pip:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-1.2.1-py2.7.egg/pip/basecommand.py", line 107, in main
File "/Library/Python/2.7/site-packages/pip-1.2.1-py2.7.egg/pip/commands/install.py", line 261, in run
File "/Library/Python/2.7/site-packages/pip-1.2.1-py2.7.egg/pip/req.py", line 1162, in install
File "/Library/Python/2.7/site-packages/pip-1.2.1-py2.7.egg/pip/req.py", line 495, in uninstall
File "/Library/Python/2.7/site-packages/pip-1.2.1-py2.7.egg/pip/req.py", line 1492, in remove
File "/Library/Python/2.7/site-packages/pip-1.2.1-py2.7.egg/pip/util.py", line 273, in renames
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 299, in move
os.unlink(src)
OSError: [Errno 13] Permission denied: '/usr/local/bin/pip'
And on all my subsequent attempts to use pip do as well:
Traceback (most recent call last):
File "/usr/local/bin/pip", 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>
line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec")
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
continue # try the next older version of project
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
pkg_resources.DistributionNotFound: pip==1.2.1
I see that similar problems have been reported before, but none of the suggestions I see help resolve this.
I'm stuck, and can't maintain my Python installation.
I'm using OS 10.8.4, Python 2.7.2 in /usr/bin/python.
According to this line:
OSError: [Errno 13] Permission denied: '/usr/local/bin/pip'
It seems like a *nix permission issue, try to launch the upgrade using sudo:
sudo pip install --upgrade pip
On a side note, I'd recommend using this upgrade method: http://www.pip-installer.org/en/latest/installing.html#install-or-upgrade-pip
tl;dr version (thanks to the information given by OP ;)):
1.Download and laucnh get-pip.py from http://www.pip-installer.org/en/latest/installing.html#install-or-upgrade-pip
2.If you get an error about "invalid command 'egg_info'", you'll need to upgrade setup tools using pip install --upgrade setuptools or easy_install -U