I have installed anaconda. Now when i am trying to run
import pandas as pd
I am getting the following error
Traceback (most re
For OSX:
I had installed this via Anaconda, and had a hell of a time getting it to work. What helped was adding the Anaconda bin AND pkgs folder to my PATH.
Since I use fishshell, I did it in my ~/.config/fish/config.fish
file like this:
set -g -x PATH $PATH /Users/cbrevik/anaconda/bin /Users/cbrevik/anaconda/pkgs
If you use fishshell like me, this answer will probably save you some trouble later using pandas as well.
You should first create a new environment in conda. From the terminal, type:
$ conda create --name my_env pandas ipython
Python will be installed automatically as part of this installation. After selecting [y] to confirm, you now need to activate this environment:
$ source activate my_env
On Windows I believe it is just:
$ activate my_env
Now, confirm installed packages:
$ conda list
Finally, start python and run your session.
$ ipython
Another alternative is to use Pycharm IDE. For each project, you can set the Project Interpreter in Settings.
For example, if anaconda is installed in /home/user/anaconda2/bin/python, you can select the Project Interpreter and set to this folder.
Since the whole project is set to Anaconda's path, you can import any module which is packaged within Anaconda.
I've had the same exact problem in that I installed Anaconda because a python script I want to use relies on pandas, and that after so doing, python still returned the same comment that "pandas module is missing" or something to that effect.
When I typed "python" to see which python was being called, I found it was still accessing the older version of python 2.7, even though when I installed Anaconda the installer asked (and I agreed) that it would make its python the default python on my machine (PC running Windows 7).
I tried to find if there is a CONFIG.SYS file on the PC, but gave up after searching in various places (If anyone knows, please tell me). I got around the problem by writing a one-line batch script named python2.bat that called the Anaconda2 version of python, which then worked. However, it would clearly be better to change the CONFIG.SYS or whatever the PC uses to decide which version of python to call.
You can only import a library which has been installed in your environment.
If you have created a new environment, e.g. to run an older version of Python, maybe you lack 'pandas' package, which is in the 'base' environment of Anaconda by default.
Fix through GUI
To add it to your environment, from the GUI, select your environment, select "All" in the dropdown list, type pandas in the text field, select the pandas package and Apply.
Afterwards, select 'Installed' to verify that the package has been correctly installed.
If you are facing same problem as mine. Here is the solution which works for me.
If you get any error, type in command prompt
pip install module_name
I hope it will work for you too