Trexion Kameha
Trexion Kameha

Reputation: 3580

python pip install to Anaconda directory

I am configuring a brand new machine and have just installed Anaconda and python.

In the command line, I type in

pip install %PACKAGENAME% 

When in a jupyter notebook, I type in:

import %PACKAGENAME%

It cannot find the package.

Turns out that when I type in sys.path, I get:

C:\\Users\\ywu\\AppData\\Local\\Continuum\\Anaconda3\\

Therefore, I have to specify the path first:

sys.path.append("C:/Users/ywu/AppData/Local/Programs/Python/Python36-32/Lib/site-packages")
import %PACKAGENAME%

This step is unnecessarily annoying. There are two options, either:

  1. automatically install into the Anaconda folder

  2. automatically import from the python36-32 libraries

Can someone please advise on what is the best practice between 1 or 2 and how I can actually accomplish 1 or 2?

Upvotes: 2

Views: 22226

Answers (1)

yxre
yxre

Reputation: 3704

Anaconda is an all-in-one environment and package manager. Pip has made some major strides forward in recent years due to pressure from anaconda being so good, so the two tools have feature parity.

On the command line, you can run

conda activate <env-name>

Then you can run

conda install <package-name>

For the most part, conda is just a proxy for pypi, so you get the exact same package as with pip.

Personally, I don't use anaconda anymore, and I just use pip. Anaconda is good for python web-dev because web projects are much pickier about dependency versions. I mostly use python for the scientific packages, and those are not as sensitive the version changes as web frameworks.

Upvotes: 2

Related Questions