问题
I don't understand how to install modules to Jupyter Notebook. I tried importing different frameworks but nothing can be imported even though I have everything installed in my system. I'm using pip.
Or maybe there's a way to point Jupyter to a certain virtualenv?
回答1:
import sys
!{sys.executable} -m pip install pandas
回答2:
Packages are usually installed using pip. You can use pip in many ways, such as :
Directly in your jupyter notebook by writing the following command:
!pip install pandas
this will save/install pandas in your default system path.
Using command prompt
pip install pandas
For this, you need to make sure that the path where pandas is being installed is same as your system path (read default path) in jupyter notebook
In case, You already have Pandas in your system and still not able to load it then it might be due to location/path of your package not defined in jupyter.You need to set the system path where your pandas package reside, you can use sys package to add the path of your package:
import sys
sys.path.append('your-path')
'your-path' is the location of pandas package on your system
回答3:
If you are getting 'permission denied' error using:
pip install pandas
try typing this in a terminal:
pip install pandas --user
This will install the library to the 'Python user install directory for your platform' which should not require admin rights to read or write to. For more details type:
pip install --help
回答4:
This works for me. Type this code in a Jupyter cell.
!pip install pandas
回答5:
If you are working in a virtualenv and you installed jupyter outside of virtualenv then jupyter-notebook couldn't recognize the packages that you've installed inside virtualenv.
You've to first install jupyter inside virtualenv i.e by first activating your virtualenv and then installing your jupyter by:
pip install jupyter
and then install your pandas package by:
pip install pandas
Hope this works!
来源:https://stackoverflow.com/questions/52235013/modulenotfounderror-no-module-named-pandas-jupyter-notebook