I installed matplotlib using (pip install --user matplotlib) and the installation was successful. when I try to import it using (import matplotlib) in python shell I get this error:
Traceback (most recent call last):
File "", line 1, in
import matplotlib
ImportError: No module named matplotlib
I couldn't find another question similar to mine because I'm not using anaconda.
Try pip uninstall matplotlib then python -mpip install matplotlib see if it helps. Otherwise, i'd recommend using a virtual environment which you can install using sudo easy_install virtualenv or pip install virtualenv This way you could just install and use matplotlib by following these steps:
Create a new virtual environment : user#yourmac$ virtualenv .env (.env can be any name or directory)
Activate it by doing : user#yourmac$ source .env/bin/activate
Then once it's activated just do a pip install matplotlib and use it to your satisfaction.
Hopefully this should solve your problem.
Related
Using Python Jupyter notebooks to work in an environment I've created. Everything went fine until I decided to add another package to the environment. After setting up the environment, I was unable to import additional packages I installed in the environment. I was only able to import packages I installed on set-up.
Here are the commands I used to create the environment initially:
python -m venv test
. test/bin/activate
pip install pyodbc
deactivate
python3 -m ipykernel install --user --name test
This all worked fine. I started a notebook using the new environment and was able to import pyodbc without error!
Then I decided I wanted to add another package, geopandas.
. test/bin/activate
pip install geopandas
deactivate
I opened a notebook in the kernel and tried
import geopandas
ModuleNotFoundError Traceback (most recent call last)
/tmp/ipykernel_47903/1529612126.py in <module>
----> 1 import geopandas
ModuleNotFoundError: No module named 'geopandas'
I then attempted linking it to ipykernel again
python3 -m ipykernel install --user --name test
But I still received the same error in the notebook and was unable to import the package. How can I add more packages to an environment after already establishing it? I'm not sure what I'm doing wrong. Thank you!
I'm using Python 3.8(64-bit)
Basically, I tried every possible solution on the internet like update the python version and tensorflow version etc.
But when I try to do this:
import tensorflow_quantum as tfq
terminal always say:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow_quantum'
Does anyone have any idea on this issue? Cheers
Please run the following:
pip3 install --upgrade pip
pip3 install tensorflow==2.3.1
pip3 install -U tensorflow-quantum
I have faced quite a similar problem and I followed this link for some help
in short I created a virtual environment with
python version == 3.6.2
conda create -n your_new_env_name python=3.6.2 anaconda
and then activated this environment as follows before you continue
conda activate your_new_env_name
then installed tensorflow
pip install tensorflow==2.1.0
pip install tensorflow-gpu=2.0.0
pip install tensorflow-quantum
you may face 2 errors which you might need to be solved
the first is this
When importing tensorflow, I get the following error:
No module named 'numpy.core._multiarray_umath'
all you have to do is this
pip install numpy --upgrade
or if needed
pip install numpy --upgrade --user
you may also get an error when import tensorflow-quantum that's related to google.api_core and what solved the problem for me was to do the following
pip install google.api_core==1.16.0
you may also need to the following
pip install cython
I hope it works!
I followed these instructions to get a python virtual environment (managed by pyenv) working in a Jupyter Notebook.
In summary, I did
brew install pyenv
pyenv install 3.8.5
pyenv virtualenv 3.8.5 myproject
pyenv shell myproject
pip install jupyter notebook matplotlib pandas numpy scipy
Then I started up jupyter notebook from terminal (I tried both jupyter notebook and jupyter lab). When I typed import numpy as np, I get
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-0aa0b027fcb6> in <module>
----> 1 import numpy as np
ModuleNotFoundError: No module named 'numpy'
But in the very next cell, if I evaluate !pip install numpy, I get
Requirement already satisfied: numpy in /Users/<my_username>/.pyenv/versions/3.8.5/envs/myproject/lib/python3.8/site-packages (1.19.1)
And also, !which python and !which pip return
/Users/<my_username>/.pyenv/shims/pip
/Users/<my_username>/.pyenv/shims/python
How is it even possible that in the very same jupyter notebook, it can't find numpy but pip says numpy is already installed? I can never seem to get my Python environments to just behave!
I had the exact same issue. I think it's all due to your "varying pip list". You probably have installed bunch of libraries via pip install before you created the shims path (prior your pyenv installation). You may also have installed some others after the shims creation. So your jupyter-notebook and jupyter-lab may not have access to the priorly installed libraries.
Since you have installed pyenv via homebrew, without touching anything else just re-installing the jupyterlab via homebrew might take care of it.
I used this:
brew install jupyterlab
And it solved my problem.
source: https://formulae.brew.sh/formula/jupyterlab
in my code, there are
import seaborn
and they give me
no module named seaborn
when I use
pip install seaborn
it gives me Requirement already satisfied but I still couldnot import seaborn so I use pip3 install seaborn,it reports so many errors as follow:
Using cached https://files.pythonhosted.org/packages/2f/79/f236ab1cfde94bac03d7b58f3f2ab0b1cc71d6a8bda3b25ce370a9fe4ab1/pandas-1.0.3.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-c8lrjdqb/pandas/setup.py", line 42
f"numpy >= {min_numpy_ver}",
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-c8lrjdqb/pandas/
I don't know how to solve this, and I have upgraded my setuptools like:pip install --upgrade setuptools and also pip3 install --upgrade setuptools
and also I have tried conda install seaborn it looks like work well but when I run my code, it still told me no module name seaborn
so how could I install seaborn on my ubuntu?
I have checked my python version by python --version it is python3.8.
Same problem also happened with install pandas*.
Both python2 and python3 come shipped along with Ubuntu, so installing packages with just pip might be your issue as that is the default package manager for python 2.
Try the following in your terminal:
$ python3 -m pip list | grep seaborn
If you dont get an output then this shows you that seaborn hasn't been installed via pip linked to your python3 interpreter.
It is good practice to install packages for your interpreter specifically as follows:
$ python3 -m pip install <insert name of package here>
Finally to check that the package has installed correctly launch the python3 interpreter within your terminal and try and import the package e.g.
$ python3
>>> import seaborn as sns
Most of the packages for your python distribution should be in the following directory:
$ cd /usr/local/lib/python3.8/dist-packages
The above are just a few pointers to get you started, hope that helped!
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.