0

I am trying to install torch using conda however, it installs it into another conda environment not the one I am interested in. How can I fix this?

[jalal@goku NAACL2018]$ conda install pytorch torchvision -c pytorch
Solving environment: done

## Package Plan ##

  environment location: /scratch/sjn/anaconda

  added / updated specs: 
    - pytorch
    - torchvision


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    pytorch-0.4.1              |py27__9.0.176_7.1.2_2       471.4 MB  pytorch
    openssl-1.0.2p             |       h470a237_1         3.1 MB  conda-forge
    ca-certificates-2018.10.15 |       ha4d7672_0         135 KB  conda-forge
    conda-4.5.11               |        py27_1000         651 KB  conda-forge
    torchvision-0.2.1          |           py27_1         123 KB  pytorch
    ------------------------------------------------------------
                                           Total:       475.4 MB

The following packages will be UPDATED:

    ca-certificates: 2018.8.24-ha4d7672_0 conda-forge --> 2018.10.15-ha4d7672_0       conda-forge
    conda:           4.5.11-py27_0        conda-forge --> 4.5.11-py27_1000            conda-forge
    openssl:         1.0.2p-h470a237_0    conda-forge --> 1.0.2p-h470a237_1           conda-forge
    pytorch:         0.4.0-py27hd73e86b_0             --> 0.4.1-py27__9.0.176_7.1.2_2 pytorch    
    torchvision:     0.2.1-py27_0         conda-forge --> 0.2.1-py27_1                pytorch    

Proceed ([y]/n)? y


Downloading and Extracting Packages
pytorch-0.4.1        | 471.4 MB  | ##################################### | 100% 
openssl-1.0.2p       | 3.1 MB    | ##################################### | 100% 
ca-certificates-2018 | 135 KB    | ##################################### | 100% 
conda-4.5.11         | 651 KB    | ##################################### | 100% 
torchvision-0.2.1    | 123 KB    | ##################################### | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
[jalal@goku NAACL2018]$ python 
Python 3.6.4 |Anaconda custom (64-bit)| (default, Jan 16 2018, 18:10:19) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'torch'
>>> quit()
[jalal@goku NAACL2018]$ conda install pytorch torchvision -c pytorch
Solving environment: done

# All requested packages already installed.

[jalal@goku NAACL2018]$ which conda
/scratch/sjn-p3/anaconda/anaconda3/bin/conda

How can I force it to not install it in environment location: /scratch/sjn/anaconda ? And I want it to install for the python located in /scratch/sjn-p3/anaconda/anaconda3/bin/conda

  • This looks off topic for Ubuntu support. Address the question to Anaconda. It is their software. – pauljohn32 Oct 21 '18 at 5:56
0

You can use the -n or --name flag of conda install to install into a particular environment. For example,

$ conda install --name myenv pytorch torchvision -c pytorch
0

You have two options, but I note that your two locations are not environments but anaconda installations. When you use environments, that location is in env/ directory of your installation.

If both are really environments, you can:

  • Activate your environment and install

    conda activate anaconda3
    conda install pytorch torchvision -c pytorch

  • Install specifying environment

    conda install -n anaconda3 pytorch torchvision -c pytorch

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.