How to install Python packages in a specific environment?

11,338

When you are running python in the terminal, it is looking up your default path to your the python command. In this case, anaconda probably put a line in your shell profile specify the path to the anaconda version, which is why you are seeing it in the interpreter when you run python from either directory.

Secondly, you can set up a conda environment to download app specific dependencies without interfering with your default set up by

conda create --name myenv
source activate myenv
conda install packagename

This will install it in the myenv environment only. To deactivate the environment just run

source deactivate

Here is the documentation on that https://conda.io/docs/user-guide/tasks/manage-environments.html

Share:
11,338

Related videos on Youtube

Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    I installed Anaconda3 so I can create environments and install different packages in each environment. But I fail to understand the difference between the Python in

    /usr/bin/python
    

    and

    /opt/anaconda3/bin/python
    

    I can seem to access Python 3.6.5 Anaconda from both, why is that? And, what is the difference between both?

    Furthermore, I would like to install packages to a single Python environment only.

    • anishtain4
      anishtain4 almost 6 years
      just activate the environment, then pip install installs the packages only in that environment. Notice that you have to run spyder from the conda command line or it will automatically loads the root environment.
    • Admin
      Admin almost 6 years
      thanks ! what about the difference between /usr/bin/python and /opt/anaconda3/bin/python ? how are both of these connected
  • Admin
    Admin almost 6 years
    thank you! I managed to create the environment and install the package but I still cannot seem to get it to work. Check the updated version please
  • gymbrane
    gymbrane almost 6 years
    yeah, so once you have created an environment, you will need to activate it in your shell environment. In your shell, run source activate pythonoozie and then run conda install pandas from the shell.
  • Admin
    Admin almost 6 years
    yes I did that already, but it seems like I cannot point oozie to that python envirnment
  • gymbrane
    gymbrane almost 6 years
    i am just curious, when you run this command in the shell conda env list does it put the asterisk next to the envs/pythonoozie