The Question :
321 people think this question is useful
I’m having troubles with installing packages in Python 3.
I have always installed packages with
setup.py install. But now, when I try to install the ansicolors package I get:
importerror “No Module named Setuptools”
I have no idea what to do because I didn’t have setuptools installed in the past. Still, I was able to install many packages with
setup.py install without setuptools. Why should I get setuptools now?
I can’t even install setuptools because I have Python 3.3 and setuptools doesn’t support Python 3.
Why doesn’t my install command work anymore?
The Question Comments :
The Answer 1
598 people think this answer is useful
setup.py file needs
setuptools. Some Python packages used to use
distutils for distribution, but most now use
setuptools, a more complete package. Here is a question about the differences between them.
setuptools on Debian:
sudo apt-get install python3-setuptools
For an older version of Python (Python 2.x):
sudo apt-get install python-setuptools
The Answer 2
102 people think this answer is useful
EDIT: Official setuptools dox page:
If you have Python 2 >=2.7.9 or Python 3 >=3.4 installed from
python.org, you will already have pip and setuptools, but will need to
upgrade to the latest version:
On Linux or OS X:
pip install -U pip setuptools
python -m pip install -U pip setuptools
Therefore the rest of this post is probably obsolete (e.g. some links don’t work).
Distribute – is a setuptools fork which “offers Python 3 support”. Installation instructions for distribute(setuptools) + pip:
curl -O http://python-distribute.org/distribute_setup.py
Similar issue here.
UPDATE: Distribute seems to be obsolete, i.e. merged into Setuptools: Distribute is a deprecated fork of the Setuptools project. Since the Setuptools 0.7 release, Setuptools and Distribute have merged and Distribute is no longer being maintained. All ongoing effort should reference the Setuptools project and the Setuptools documentation.
You may try with instructions found on setuptools pypi page (I haven’t tested this, sorry 🙁 ):
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | python
The Answer 3
25 people think this answer is useful
I was doing this inside a virtualenv on Oracle Linux 6.4 using python-2.6 so the apt-based solutions weren’t an option for me, nor were the python-2.7 ideas. My fix was to upgrade my version of setuptools that had been installed by virtualenv:
pip install --upgrade setuptools
After that, I was able to install packages into the virtualenv. I know this question has already had an answer selected but I hope this answer will help others in my situation.
The Answer 4
15 people think this answer is useful
pip uninstall setuptools
pip install setuptools
This works for me and fix my issue.
The Answer 5
9 people think this answer is useful
The solution which worked for me was to upgrade my setuptools:
python3 -m pip install --upgrade pip setuptools wheel
The Answer 6
4 people think this answer is useful
distribute package provides a Python 3-compatible version of
pip to install the modules. It automatically finds dependencies and installs them for you.
It works just fine for me with your package:
[~] pip --version
pip 1.2.1 from /usr/lib/python3.3/site-packages (python 3.3)
[~] sudo pip install ansicolors
Running setup.py egg_info for package ansicolors
Installing collected packages: ansicolors
Running setup.py install for ansicolors
Successfully installed ansicolors
The Answer 7
3 people think this answer is useful
I have given a complete solution here for python selenium webdriver
1. Setup easy install (windows - simplified)
a. download ez.setup.py (https://bootstrap.pypa.io/ez_setup.py) from 'https://pypi.python.org/pypi/setuptools'
b. move ez.setup.py to C:\Python27\
c. open cmd prompt
d. cd C:\Python27\
e. C:\Python27\python.exe ez.setup.py install
The Answer 8
1 people think this answer is useful
The PyPA recommended tool for installing and managing Python packages is
pip is included with Python 3.4 (PEP 453), but for older versions here’s how to install it (on Windows):
Installing collected packages: pip, setuptools
Successfully installed pip setuptools
>c:\Python33\Scripts\pip.exe install pymysql
Installing collected packages: pymysql
Successfully installed pymysql
The Answer 9
1 people think this answer is useful
A few years ago I inherited a python (2.7.1) project running under Django-1.2.3 and now was asked to enhance it with QR possibilities. Got the same problem and did not find pip or apt-get either. So I solved it in a totally different but easy way.
I /bin/vi-ed the setup.py and changed the line
“from setuptools import setup”
“from distutils.core import setup”
That did it for me, so I thought I should post this for other users running old pythons.