I'm running iPhyton Notebooks and I'm trying to import the Seaborn package. When I try to import it from the Terminal, it loads up fine, but when I import it through iPython Notebooks, it give me the following error.
I have even tried to re-install Seaborn using both Conda and Pip inside iPython notebooks and still it wont work.
Any idea why?
Thanks.
ImportError Traceback (most recent call last)
<ipython-input-1-417274a1ae6c> in <module>()
1 get_ipython().system(u'conda install seaborn')
2 get_ipython().system(u'pip install seaborn')
----> 3 import seaborn as sb
4
ImportError: No module named seaborn
Try this
import sys
print sys.path
sys.path.append('<path to package in your syste>')
import seaborn
In my Ubuntu 14.4LTS the packages get installed in the following folder
/usr/local/lib/python2.7/dist-packages
So I simply add the package path at run time
Donit install Ipython on all your system. Install it only in the environments you want it. Otherwise Ipython will look for modules in the default path instead of the environment's path.
This is probably where your ipython is looking:
/home/user/anaconda2/lib/python2.7/
It should be looking for modules here:
/home/user/anaconda2/envs/name-of-env/lib/python3.4/
To check the path you type:
import sys
sys.path
Try entering the following in your terminal:
conda install seaborn
It will install seaborn and make it available for you to import into your notebook
Open anaconda prompt and Type
pip install seaborn
Related
I know that this is quite a common problem but when I installed this package I can't seem to get pyplot to be imported with matplotlib. My computer is currently running Pop os and I am using Pycharm as my IDE. When I run anything involved pyplot I get an the console prints out
Traceback (most recent call last):
File "/home/msm/PycharmProjects/Beginner/testing.py", line 1, in <module>
import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib.pyplot'; 'matplotlib' is not a package
I have already tried the following
sudo apt-get install python3-matplotlib in the terminal
Searching for the package within Pycharm
Updating Python
Any help would be greatly appreciated.
try:
pip install matplotlib
if it isn't working try:
pip install --upgrade pip
and try it again
if it isn't working again try start terminal with administrator and add python -m to head of code
I have installed 'pandas_profiling' through conda install -c conda-forge pandas-profiling in the base environment. I could see through the conda list that pandas_profiling has been installed correctly (snapshot attached),
When I try to import pandas_profiling I receive ModuleNotFoundError
import pandas_profiling
Traceback (most recent call last):
File "<ipython-input-4-60d2bac64bfc>", line 1, in <module>
import pandas_profiling
ModuleNotFoundError: No module named 'pandas_profiling'
Update: output of import sys; print(sys.path); print(sys.prefix)
['/home/user1/miniconda3/lib/python38.zip', '/home/user1/miniconda3/lib/python3.8', '/home/user1/miniconda3/lib/python3.8/lib-dynload', '', '/home/user1/miniconda3/lib/python3.8/site-packages', '/home/user1/miniconda3/lib/python3.8/site-packages/IPython/extensions', '/home/user1/.ipython']
/home/user1/miniconda3
This is a frequent issue, check out this entry in the FAQ.
Occasionally you will encounter this error if you import a package from the current notebook. It is important to ensure that the pip version is associated with the current Python kernel. That way, the installed packages can be used in the current notebook.
As detailed here, the shell environment and the Python executable are disconnected.
This should work for you
import sys
!{sys.executable} -m pip install pandas-profiling
I'm trying to use the seaborn module in jupyter notebook,I alredy installed all the dependecies and the seaborn too,but when I try to run,it's said that it does not have a module seaborn installed
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-ed806232820c> in <module>
1 import pandas as pd
2 import matplotlib.pyplot as plt
----> 3 import seaborn as sns
ModuleNotFoundError: No module named 'seaborn'
Try restarting notebook first.
Make sure that seaborn is installed by same python interpreter used in the notebook.
Easiest way to be certain of this is to run
!pip install --user seaborn in the active notebook (! allows you to run shell command from your notebook)
Additional info for detecting the cause of the problem
You can check which interpreter is used by the notebook by running:
import sys
print(sys.executable)
I assume pip you used initially is not used by python you used to run the notebook (multiple python installations of the system or conda).
To specify which python is used for pip install you can run
<python-path> -m pip install seaborn where <python-path> is output of sys.executable.
I am trying to run some code that has 'import websocket' however I am getting the error: ModuleNotFoundError: No module named 'websocket'
I have Python 3.7.3 and I am running in Spyder (if that makes a difference).
So from other questions/answers I found on here, in my cmd I ran pip install websocket and then also pip install websocket-client when the first one didn't run.
I am still getting the ModuleNotFoundError. Does it matter the location/folder of the code or where I install the pip command in cmd?
My python code starts with these import statements:
import json
import websocket
import traceback
import helper
import ssl
import time as time
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import griddata
from mpl_toolkits.mplot3d import Axes3D
In cmd I ran:
C:\Users\myname>pip install websocket
and also:
C:\Users\myname>pip install websocket-client
The error I am getting is:
File "C:/Users/micki/Downloads/Derbit-Volatility-Visulization-master/Derbit-Volatility-Visulization-master/Volatility Surface Class.py", line 2, in <module>
import websocket
ModuleNotFoundError: No module named 'websocket'
Not sure, as you did not cover how you installed and are using Spyder, though I think it is probably an issue with your environment. You might also find that you are missing the module "helper" as well. There's two easy options as follows:
If you installed and are using Spyder via conda or anaconda, follow their documentation on installing websocket-client to the correct environment found here.
The second option (the preferred option IMHO, as you can use any IDE or text editor going forward), regardless of how you installed Spyder, would be to create a python virtual environment python3 -m venv /path/to/new/virtual/environment, pip install all your dependencies in said environment, then link Spyder's interpreter to the interpereter that was installed when you made the environment. In Spyder, go to Tools -> Preferences -> Python interpreter -> check the "Use the following Python interpreter:" radio button and enter the path to the interpreter from the environment you just created. For reference, see docs on making and using a python venv here.
If the websocket and websocket-client doesn't work, try:
pip install websocket_client
This solved my issue:
sudo pip install websocket-client
I tried to upgrade matplotlib using pip install --upgrade matplotlib, then after upgrading an import error occurred: import matplotlib.pyplot as plt
ImportError: No module named artist
The whole error is:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-18-eff513f636fd> in <module>()
----> 1 import matplotlib.pyplot as plt
C:\Users\TZ\AppData\Local\Continuum\Anaconda2\lib\site-packages\matplotlib\pyplot.py in <module>()
25
26 import matplotlib
---> 27 import matplotlib.colorbar
28 from matplotlib import style
29 from matplotlib import _pylab_helpers, interactive
C:\Users\TZ\AppData\Local\Continuum\Anaconda2\lib\site-packages\matplotlib\colorbar.py in <module>()
30
31 import matplotlib as mpl
---> 32 import matplotlib.artist as martist
33 import matplotlib.cbook as cbook
34 import matplotlib.collections as collections
ImportError: No module named artist
Anyone could solve this problem? (PS: I use python 2.7)
When I faced this issue (system: Windows - 64 bit OS) after upgrading Anaconda to the latest version (yesterday), I saw that Anaconda was trying to load the package from a location different from the default site-packages. Hence:
I fist checked the path my jupyter notebook was defaulting to as mentioned in one of the git hub posts (sorry I don't remember which one) using:
import sys
print(sys.path)
Since this path is not the default site-packages folder, I uninstalled Anaconda completely from add or remove programs - Anaconda (this will take some time to uninstall)
Anaconda will also remove jupyter notebook from your system. Hence, just reinstall jupyter notebook alone and open it from command line using
jupyter notebook
When you now try to import the matplotlib.pyplot in your notebook, it should not give any errors and you can use the same sys.path to check the path it is defaulting to. It should look something like:
Now, it is importing from the site-packages folder.
I am yet to investigate why and how this issue was caused but removing the upgraded Anaconda version helped me.
Run this command on your prompt:
pip install --user matplotlib --force
If it asks any packages related to it. Please install them also . It succeded for me. I hope for you also
Running this command worked for me:
conda install matplotlib --force