ImportError: No module named pkg_resources on installing matplotlib - python

This is on CentOs 6.6. I am trying to set up a scientific python environment. I want to avoid Anaconda. When trying to install matplotlib, I get "ImportError: No module named pkg_resources". Full install history:
sudo yum install gcc-c++.x86_64
sudo yum install gcc
sudo yum install atlas atlas-devel lapack-devel blas-devel
sudo yum install python-devel
sudo pip install numpy
sudo pip install scipy
sudo pip install pandas
sudo pip install matplotlib
At the last step, I get the message
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'.
Then I do
sudo pip install --upgrade distribute
which installs distribute-0.7.3, setuptools-18.0.1. Then:
sudo pip install matplotlib
which results in:
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
Any ideas?
Update
After the above steps, setuptools and pip are broken in this installation. From a python shell, doing help() followed by modules does not list setuptools. A search in the filesystem for setuptools directories reveals:
/usr/lib/python2.6/site-packages/setuptools-18.0.1.dist-info/
while the setuptools.pth file in /usr/lib/python2.6/site-packages/ contains a pointer to the non-existent ./setuptools-0.6c11-py2.6.egg-info.
At the same time, there is a directory
/usr/share/doc/python-setuptools-0.6.10/
After all this, pip no longer works.

#pavan they said CentOS, so apt is unlikely to help them.
They could, though, do :
yum remove python-setuptools
yum install python-setuptools
(my also need to reinstall pip: yum install python-pip )
And that might fix the problem.

Try this for OS supporting apt-get (Ubuntu etc)
sudo apt-get install python-pkg-resources python-setuptools --reinstall

Try install python-pip (and dependencies):
yum install python-pip
This solved my problem (Centos release 6.8).

Related

Not able to install setuptools on linux mint

I used this command in terminal
sudo apt-get install python-setuptools
it throws up an error instead of installing -
Package 'python-setuptools' has no installation candidate
THis is a python package so you could use pip to install it
pip3 install setuptools
Try this:
sudo apt-get install python-pip
When pip is installed type in:
pip install setuptools
Hope this helps!

Cannot install h5py

I'm trying to install h5py, but when I do pip install h5py or use python setup.py install from the source code, fatal error:
hdf5.h: No such file or directory.
Other posts mention to do pip install libhdf5-dev or pip install libhdf5-serial-dev to resolve this, but it says "no matching distribution found."
How can I install h5py? I am ssh'd into an Odyssey computer using the CentOS 6.5 version of the Linux. Also, I do not have sudo privileges. Thanks!
Your error is because you are missing the hdf5.h header, pip will not install the development headers, you need to install them using your package manager, on Centos it would be:
yum install hdf5-devel
If you look at the installation instrcutions:
Source installation on Linux and OS X
You need, via apt-get, yum or Homebrew:
Python 2.6, 2.7, 3.3, or 3.4 with development headers (python-dev or similar)
HDF5 1.8.4 or newer, shared library version with development headers (libhdf5-dev or similar)
NumPy 1.6.1 or later
This link helped:
https://github.com/Homebrew/legacy-homebrew/issues/23144
I installed LinuxHomeBrew and did:
brew tap homebrew/science
brew install hdf5
pip install h5py
I was able to install h5py!
sudo apt-get update
sudo apt-get install python-h5py
(Source)
Also, not pip install libhdf5-dev or pip install libhdf5-serial-dev, but apt install libhdf5-dev and apt install libhdf5-serial-dev.
Then, run pip install h5py
Running the below fixed my problem as I had an error related to xlocale.h
sudo ln -s /usr/include/locale.h /usr/include/xlocale.h

Can't install zbar

I am trying to use the qrtools module with Python 3.4.2 on my Raspberry Pi 2, however it cannot run as I don't have the zbar module installed.
Trying
pip-3.2 install zbar
Gives the error message shown in the picture
sudo pip-3.2 install zbar
gives a similar error
Any ideas?
(I do have it installed with Python 2.7)
UPDATE: Both libzbar-dev and python3-dev are up to date. Still...
No module named 'zbar'
assuming you're using a debian derivative (like ubuntu), you need to install zbar's developement package, which contains the header file zbar.h
$ sudo apt-get install libzbar-dev
for redhat/fedora systems:
$ sudo yum install zbar-devel
and probably python's dev package too:
$ sudo apt-get install python3-dev
or you can use pip install zbar-py
https://pypi.org/project/zbar-py/
Try the following code after entering sudo mode:
yum install zbar-devel
This should work for fedora.
Bumping #herve solution
On ubuntu and on Mint
sudo apt-get install python-zbar libzbar-dev python-qrtools
pip install libzbar-cffi==0.2.1

Error while installing ggplot in python

I am getting this error when trying to install ggplot in Python:
ImportError: cannot import name unpack_url
I am using the following command:
sudo pip install ggplot
This error is in a linux environment, running fedora 21.
Looks like you might need to update your version of pip itself.
Entertainingly, you can upgrade pip using pip, as per the docs:
On Debian and Ubuntu:
sudo apt-get install python-pip
On Fedora:
sudo yum install python-pip

Install line 'pip install scipy' fails [duplicate]

It is possible to install NumPy with pip using pip install numpy.
Is there a similar possibility with SciPy? (Doing pip install scipy does not work.)
Update
The package SciPy is now available to be installed with pip!
Prerequisite:
sudo apt-get install build-essential gfortran libatlas-base-dev python-pip python-dev
sudo pip install --upgrade pip
Actual packages:
sudo pip install numpy
sudo pip install scipy
Optional packages:
sudo pip install matplotlib OR sudo apt-get install python-matplotlib
sudo pip install -U scikit-learn
sudo pip install pandas
src
An attempt to easy_install indicates a problem with their listing in the Python Package Index, which pip searches.
easy_install scipy
Searching for scipy
Reading http://pypi.python.org/simple/scipy/
Reading http://www.scipy.org
Reading http://sourceforge.net/project/showfiles.php?group_id=27747&package_id=19531
Reading http://new.scipy.org/Wiki/Download
All is not lost, however; pip can install from Subversion (SVN), Git, Mercurial, and Bazaar repositories. SciPy uses SVN:
pip install svn+http://svn.scipy.org/svn/scipy/trunk/#egg=scipy
Update (12-2012):
pip install git+https://github.com/scipy/scipy.git
Since NumPy is a dependency, it should be installed as well.
In Ubuntu 10.04 (Lucid), I could successfully pip install scipy (within a virtualenv) after installing some of its dependencies, in particular:
$ sudo apt-get install libamd2.2.0 libblas3gf libc6 libgcc1 libgfortran3 liblapack3gf libumfpack5.4.0 libstdc++6 build-essential gfortran libatlas-sse2-dev python-all-dev
To install scipy on windows follow these instructions:-
Step-1 : Press this link http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy to download a scipy .whl file (e.g. scipy-0.17.0-cp34-none-win_amd64.whl).
Step-2: Go to the directory where that download file is there from the command prompt (cd folder-name ).
Step-3: Run this command:
pip install scipy-0.17.0-cp27-none-win_amd64.whl
I tried all the above and nothing worked for me. This solved all my problems:
pip install -U numpy
pip install -U scipy
Note that the -U option to pip install requests that the package be upgraded. Without it, if the package is already installed pip will inform you of this and exit without doing anything.
If I first install BLAS, LAPACK and GCC Fortran as system packages (I'm using Arch Linux), I can get SciPy installed with:
pip install scipy
On Fedora, this works:
sudo yum install -y python-pip
sudo yum install -y lapack lapack-devel blas blas-devel
sudo yum install -y blas-static lapack-static
sudo pip install numpy
sudo pip install scipy
If you get any public key errors while downloading, add --nogpgcheck as parameter to yum, for example:
yum --nogpgcheck install blas-devel
On Fedora 23 onwards, use dnf instead of yum.
For the Arch Linux users:
pip install --user scipy prerequisites the following Arch packages to be installed:
gcc-fortran
blas
lapack
Addon for Ubuntu (Ubuntu 10.04 LTS (Lucid Lynx)):
The repository moved, but a
pip install -e git+http://github.com/scipy/scipy/#egg=scipy
failed for me... With the following steps, it finally worked out (as root in a virtual environment, where python3 is a link to Python 3.2.2):
install the Ubuntu dependencies (see elaichi), clone NumPy and SciPy:
git clone git://github.com/scipy/scipy.git scipy
git clone git://github.com/numpy/numpy.git numpy
Build NumPy (within the numpy folder):
python3 setup.py build --fcompiler=gnu95
Install SciPy (within the scipy folder):
python3 setup.py install
In my case, it wasn't working until I also installed the following package : libatlas-base-dev, gfortran
sudo apt-get install libatlas-base-dev gfortran
Then run pip install scipy
install python-3.4.4
scipy-0.15.1-win32-superpack-python3.4
apply the following commend doc
py -m pip install --upgrade pip
py -m pip install numpy
py -m pip install matplotlib
py -m pip install scipy
py -m pip install scikit-learn
The answer is yes, there is.
First you can easily install numpy use commands:
pip install numpy
Then you should install mkl, which is required by Scipy, and you can download it here
After download the file_name.whl you install it
C:\Users\****\Desktop\a> pip install mkl_service-1.1.2-cp35-cp35m-win32.whl
Processing c:\users\****\desktop\a\mkl_service-1.1.2-cp35-cp35m-win32.whl
Installing collected packages: mkl-service
Successfully installed mkl-service-1.1.2
Then at the same website you can download scipy-0.18.1-cp35-cp35m-win32.whl
Note:You should download the file_name.whl according to you python version, if you python version is 32bit python3.5 you should download this one, and the "win32" is about your python version, not your operating system version.
Then install file_name.whl like this:
C:\Users\****\Desktop\a>pip install scipy-0.18.1-cp35-cp35m-win32.whl
Processing c:\users\****\desktop\a\scipy-0.18.1-cp35-cp35m-win32.whl
Installing collected packages: scipy
Successfully installed scipy-0.18.1
Then there is only one more thing to do: comment out a specfic line or there will be error messages when you imput command "import scipy".
So comment out this line
from numpy._distributor_init import NUMPY_MKL # requires numpy+mkl
in this file: your_own_path\lib\site-packages\scipy__init__.py
Then you can use SciPy :)
Here tells you more about the last step.
Here is a similar anwser to a similar question.
Besides all of these answers,
If you install python of 32bit on your 64bit machine, you have to download scipy of 32-bit irrespective of your machine.
http://www.lfd.uci.edu/~gohlke/pythonlibs/
In the above URL you can download the packages and command is: pip install
For gentoo, it's in the main repository:
emerge --ask scipy
You can also use this in windows with python 3.6 python -m pip install scipy

Categories