1

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?

Parfait
  • 104,375
  • 17
  • 94
  • 125
Trexion Kameha
  • 3,362
  • 10
  • 34
  • 60

2 Answers2

2

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.

yxre
  • 3,576
  • 21
  • 20
0

You can save the folder with Anaconda in it within the same folder that the python file is in and then write something like

from whateverthefolderisinhere import Anaconda

Hope that helps