Trying to upgrade matplotlib as in this post, I ran
export PYTHONHOME=/usr/lib/python2.7/
sudo easy_install -U distribute
sudo pip install --upgrade matplotlib
Now whenever I try to run python I get ImportError: no module named os. What happened? Please help me. I'm on OS X 10.9.5.
The issue was changing PYTHONHOME, which could not find any modules because I have python running out of a user directory /Users/alavin89/Library/Python/2.7/lib/python/site-packages. Check the python path by running echo $PYTHONPATH.
The fix:
unset PYTHONHOME
sudo pip uninstall matplotlib
pip uninstall matplotlib
pip install --user matplotlib
Note: running uninstall again w/o sudo is to double-check it worked properly.
Use Anaconda.
https://store.continuum.io/cshop/anaconda/
It has every Python package you could possibly think of - including matplotlib - it updates them all at once as well.
Related
I have my virtualenv created in ~/Desktop/env. During install it states that pip was installed successfully, along with setuptools and wheel. After activation I attempted to install a module in my virtualenv using pip but was given this error:
File "/Users/myname/Desktop/hello/env_test/bin/pip3.7", line 5, in <module>
from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip._internal.cli.main'
Looking in the bin folder there are three pips - pip, pip3, and pip3.7. Running any of these commands gives me the error above.
Can anyone help me out here? pip3 works just fine outside of the virtual environment.
Thanks.
I had the same issue and re-installing pip (not upgrading) solved the problem on Mac OS: https://pip.pypa.io/en/stable/installing/
There is an issue with newer version of pip after 20.0.0 release https://github.com/pypa/pip/issues/7620
Suggested fix
pip install -U pip
NOTE: For anyone having this is issue in their CI try cleaning caches
I had exactly the same issue. A simple work around worked for me.
For python3, in the virtualenv, when running pip commands, instead of directly using pip, use python3 -m pip.
For example, use:
python3 -m pip install xx
instead of
pip install xx
Can you please post the commands you are issuing to install the environment?
I can suggest you to install pipenv and then try with:
pipenv install
pipenv shell
I am trying to use skimage on mac, and already install the packages with virtualenv, but when I do "from skimage import io", it gave me this error :"ImportError: No module named skimage".
I am wondering if there is anything wrong installation process, but so far I cannot figure it out.
Below is my installation process:
sudo pip install virtualenv
cd /my/project/folder
virtualenv myproject
source myproject/bin/activate
pip install -U scikit-image
Then the result is:
"Successfully installed PyWavelets-0.5.2 cycler-0.10.0 decorator-4.0.11 functools32-3.2.3.post2 matplotlib-2.0.0 networkx-1.11 numpy-1.12.1 olefile-0.44 pillow-4.0.0 python-dateutil-2.6.0 pytz-2017.2 scikit-image-0.13.0 scipy-0.19.0 subprocess32-3.2.7"
It seems that I already have everything, but why import skimage still failed?
Besides, I also tried to used the installation guidance on http://scikit-image.org/download with "pip install -U scikit-image" and "easy_install -U scikit-image", but also failed.
I am on Mac Sierra, with python 2.7. Any suggestion would highly appreciated. Thanks!
conda environment manager fixes this problem.
conda install --yes -c conda-forge scikit-image
I'm using Linux and I couldn't get it working without doing
sudo apt-get install python-skimage
And I got that from the installation page of the docs:
http://scikit-image.org/docs/stable/install.html
I'm not familiar with osx, but maybe try using a package manager like homebrew to install the package like so.
sudo homebrew install python-skimage
I'm actually quite puzzled as to why theres no OSX section in the install section of the docs, but a tiny bit of information in the downloads section.
I am receiving the following error message
ImportError: cannot import name 'style'
when I run
from matplotlib import style
I am using ubuntu and have tried running it with python3 and python.
I have version (1.3.1) of matplotlib installed, which is the most up-to-date that apt-get installs. I have installed numpy and installed matplotlib with python3. No joy.
Has anybody else been having the same issue ?
sudo pip install --upgrade matplotlib
Did the trick. Although on my machine it initially threw up some issues. There are a number of helpful suggestions on this thread for anyone else having the issue
ubuntu 14.04, pip cannot upgrade matplotllib
You can also use pip install --user --upgrade matplotlib
Using sudo is deemed unsafe as you're allowing pip to execute code from the internet as root.
Using --user :
..makes pip install packages in your home directory instead, which doesn't require any special privileges Purpose of --user
More information on this here: What are the risks of running 'sudo pip'?
I had the same problem using Anaconda and IPython 3.1. You can update matplotlib to its latest version after you have installed Anaconda. Just remind that you may want to use the installer for Python 3. You will find the style module by using both the matplotlib library and matplotlib.pyplot.
I am trying to run Google's deep dream. For some odd reason I keep getting
ImportError: No module named google.protobuf
after trying to import protobuf. I have installed protobuf using sudo install protobuf. I am running python 2.7 OSX Yosemite 10.10.3.
I think it may be a deployment location issue but i cant find anything on the web about it. Currently deploying to /usr/local/lib/python2.7/site-packages.
There is another possibility, if you are running a python 2.7.11 or other similar versions,
sudo pip install protobuf
is ok.
But if you are in a anaconda environment, you should use
conda install protobuf
Locating the google directory in the site-packages directory (for the proper latter directory, of course) and manually creating an (empty) __init__.py resolved this issue for me.
(Note that within this directory is the protobuf directory but my installation of Python 2.7 did not accept the new-style packages so the __init__.py was required, even if empty, to identify the folder as a package folder.)
...In case this helps anyone in the future.
In my case I
downloaded the source code, compiled and installed:
$ ./configure
$ make
$ make check
$ sudo make install`
for python I located its folder(python) under source code, and ran commands:
$ python setup.py build
$ python setup.py install'
Not sure if this could help you..
I got the same error message when I tried to use Tensor Flow. The solution was simply to uninstall Tensor Flow and protobuf:
$ sudo pip uninstall protobuf
$ sudo pip uninstall tensorflow
And reinstall it again: pip installation of Tensorflow. Currently, this is:
# Ubuntu/Linux 64-bit, CPU only:
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0rc0-cp27-none-linux_x86_64.whl
# Ubuntu/Linux 64-bit, GPU enabled:
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.8.0rc0-cp27-none-linux_x86_64.whl
# Mac OS X, CPU only:
$ sudo easy_install --upgrade six
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0rc0-py2-none-any.whl
when I command pip install protobuf, I get the error:
Cannot uninstall 'six'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
If you have the same problem as me, you should do the following commands.
pip install --ignore-installed six
sudo pip install protobuf
According to your comments, you have multiply versions of python
what could happend is that you install the package with pip of anthor python
pip is actually link to script that donwload and install your package.
two possible solutions:
go to $(PYTHONPATH)/Scripts and run pip from that folder that way you insure
you use the correct pip
create alias to pip which points to $(PYTHONPATH)/Scripts/pip and then run pip install
how will you know it worked?
Simple if the new pip is used the package will be install successfully, otherwise the package is already installed
I installed the protobuf with this command:
conda install -c anaconda protobuf=2.6.1
(you should check the version of protobuf)
In my case, MacOS has the permission control.
sudo -H pip3 install protobuf
I had this problem to when I had a google.py file in my project files.
It is quite easy to reproduce.
main.py: import tensorflow as tf
google.py: print("Protobuf error due to google.py")
Not sure if this is a bug and where to report it.
I installed a module called mrjob using sudo pip install mrjob. When I start python and try to import it, I get ImportError: No module named mrjob.
Using iname, I find out that mrjob is installed in /lib/python2.7/site-packages/, while all my Python modules are in /usr/local/lib/python2.7/site-packages. So I add the new folder to my PATH with export PATH=/lib/python2.7/site-packages:$PATH.
But even after I do that, I still get ImportError. If I cd to /lib/python2.7/site-packages/ and start python from there, it imports the module correctly.
I also tried to uninstall the module:
> sudo pip uninstall mrjob
Password:
Cannot uninstall requirement mrjob, not installed
If I do:
>>> import site; site.getsitepackages()
['/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages', '/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/site-python', '/Library/Python/2.7/site-packages']
The folder /lib/python2.7/site-packages/ isn't there.
== UPDATE ==
The following command worked
pip install --install-option="--prefix=/usr/local" mrjob
I can now import mrjob correctly. But I still don't understand what is going on.
I got this problem too. Cause python use the system pre-install python at
/Libarary/Python
But this python without pip. while I install pip, it will install at
/usr/local/Libarary/Python
My solution is install pip for the system by this:
sudo easy_install -U pip