Jupyter python3 notebook cannot recognize pandas

后端 未结 14 955
终归单人心
终归单人心 2020-12-14 15:56

I am using the Jupyter notebook with Python 3 selected. On the first line of a cell I am entering:

import pandas as pd

The error I get from

相关标签:
14条回答
  • 2020-12-14 16:17

    This is what i have done in my system:

    I have installed both anaconda for python 2.7 and anaconda for python 3.5. Anaconda helps keep both the environment separate.

    In Ubuntu:

    The directory structure is like this: anaconda2/bin/ anaconda3/bin/

    Whenever i want to use python 2.7 i go to anaconda2/bin/ and create an environment or activate already existing environment and install or import all the necessary packages and same goes for python3.5 (go to anconda3/bin/ create or activate the required environment). This helps me keep things separate.

    Since you are using anaconda you should first use "conda install " if that package is not found, then you can use pip install .

    In Windows:

    If you install both anaconda2 and anaconda3, its quite easy.. the shortcuts for anaconda prompt are in C:\Users\your-username\

    there will be two folders anconda2 and anaconda3, you can start conda prompt for python2.7 from anaconda2 and python3.5 from anconda3

    So, once you start the anaconda prompt you can just type "jupyter notebook" to open jupyter notebook in browser and import pandas(or any package).

    You can check this link:

    http://conda.pydata.org/docs/test-drive.html#managing-conda

    0 讨论(0)
  • 2020-12-14 16:20

    Maybe its a broken (pip) installation. Following worked for me:

    sudo apt --fix-broken install

    Followed by:

    sudo pip3 install pandas

    Hope this helps.

    0 讨论(0)
  • 2020-12-14 16:23

    As your default python version is 2.x , if you don't have any emphasis on the python 3.x you can try from the first by the below scripts.

    pip install --upgrade pip
    pip install jupyter
    

    then in jupyter notebook:

    !pip install pandas
    

    The version of notebook will be 2.x. Otherwise install pip3 by the below Linux commands.

    sudo apt-get install python3-setuptools
    sudo easy_install3 pip
    

    now you can add pandas to the notebook by !pip3 install pandas.

    0 讨论(0)
  • 2020-12-14 16:23

    For Windows

    The first step is to create a new conda environment. A conda environment is like a virtualenv that allows you to specify a specific version of Python and set of libraries. Run the following commands from a terminal window:

    conda create -n name_of_my_env python
    

    This will create a minimal environment with only Python installed in it. To put your self inside this environment run:

    source activate name_of_my_env
    

    On Windows the command is:

    activate name_of_my_env
    

    The final step required is to install pandas. This can be done with the following command:

    conda install pandas
    

    To install a specific pandas version:

    conda install pandas=0.20.3
    

    To install other packages, IPython for example:

    conda install ipython
    

    To install the full Anaconda distribution:

    conda install anaconda
    

    If you need packages that are available to pip but not conda, then install pip, and then use pip to install those packages:

    conda install pip
    pip install django
    
    0 讨论(0)
  • 2020-12-14 16:28

    simple step to resolve the problem is

    ( NOTE: Remember what you have selected python 2 or python 3).

    for python 2+

    !pip install pandas
    

    or if you have user permission error type

    !pip install pandas --user
    

    for python 3+

    !pip3 install pandas
    

    or if you have user permission error type

    !pip3 install pandas --user
    
    0 讨论(0)
  • 2020-12-14 16:28

    This worked for me

    1. in Jupiter notebook

      import sys
      print(sys.executable) 
      
    2. copy path eg:

       /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
      
    3. install the module on the terminal like this.

      /Library/Frameworks/Python.framework/Versions/3.7/bin/python3 -m pip install pandas
      
    0 讨论(0)
提交回复
热议问题