ModuleNotFoundError: No module named 'pandas' (jupyter notebook)

邮差的信 提交于 2019-12-11 17:31:42

问题


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 :

  1. Directly in your jupyter notebook by writing the following command:

    !pip install pandas

this will save/install pandas in your default system path.

  1. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!