Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Installing From Source" Within Anaconda Environment

What I would like to do:

  • I am using macOS and Anaconda 2.
  • I would like to install a Python package (specifically PyTorch) from source.
  • I would like to install all the dependencies and the package itself within an Anaconda environment.
  • I don't want this Anaconda environment to be the default/ root Anaconda environment, but an environment I particularly created for installing this package and its dependencies from source.

What I have done:

First, I created the environment as follows

conda create --name my_env python=3.5

Now, the instructions for installing PyTorch from source are as follows:

export CMAKE_PREFIX_PATH=[anaconda root directory]
conda install numpy pyyaml setuptools cmake cffi
git clone --recursive https://github.com/pytorch/pytorch
MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py install

Now, my questions are:

  1. Following this instructions, requires me to specify anaconda root directory for the CMAKE_PREFIX_PATH. What should that directory be given that I want everything set-up in my_env?
  2. Is it reasonable to create an extra environment for a package installed from source and its dependencies? Why would one do or not do it? My motivation is mainly fear that one day I may screw my system up big time and hence want things to be cleanly separated.

If you can only answer one of the two questions, that is already greatly appreciated. Thanks!

like image 270
mbpaulus Avatar asked Dec 13 '17 18:12

mbpaulus


People also ask

How do I install packages in Anaconda base environment?

Go to Environments tab just below the Home tab and from there we can check what all packages are installed and what is not. It is very easy to install any package through anaconda navigator, simply search the required package, select package and click on apply to install it.

Can I install with pip in conda environment?

You can install pip in the current conda environment with the command conda install pip , as discussed in Using pip in an environment. If there are instances of pip installed both inside and outside the current conda environment, the instance of pip installed inside the current conda environment is used.

What is the difference between conda install and pip install?

The fundamental difference between pip and Conda packaging is what they put in packages. Pip packages are Python libraries like NumPy or matplotlib . Conda packages include Python libraries (NumPy or matplotlib ), C libraries ( libjpeg ), and executables (like C compilers, and even the Python interpreter itself).

Where does conda install from?

Conda installs packages into the anaconda/pkgs directory. If conda cannot find the file, try using an absolute path name instead of a relative path name. Installing packages directly from the file does not resolve dependencies.


1 Answers

I received this answer from the Anaconda Google discussion group and re-post it here in case anyone else is interested.

  1. It is the path to my_env. If you created it with -n my_env and you haven't otherwise changed your envs dir, it'll be in <anaconda root>/envs/my_env

  2. Yes, this is definitely good practice. The cleanest way to use conda is to install miniconda, not anaconda, and to install as little as possible into the root environment.

like image 194
mbpaulus Avatar answered Oct 20 '22 01:10

mbpaulus