简体   繁体   中英

installing python 2.7 package with anaconda

I am trying to figure out how to install packages for the first time. I have downloaded Python 2.7 with the Anaconda distribution. When I go to terminal and I type:

pip install pandas-datareader

I see a message that the package was installed successfully. However, when I enter:

import pandas-datareader as pdr

into Spyder, I get the error:

No module named pandas-datareader

I think this might be because I am not installing the package in the right directory. I also tried:

 conda install -c anaconda pandas-datareader 

and got the same result. I know there are many posts about installing packages, but I am looking for a super basic beginner explanation for how to troubleshoot this. What directory should I save packages in? How do I navigate to that directory? How do I use terminal to download the package into that directory, etc.

Conda installs any package to a conda environment and pip installs python packages to any environment. Your best bet is to create an environment and conda install to that. For example,

conda create -n py35
activate py35
conda install package_name

Typing these into the command line will set up your environment, activate it, and install whatever package you want.

After following your link, I got it to work by entering

!pip install pandas-datareader

in the Spyder Ipython console!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM