I am trying to run a pytorch code that was written in python 2.7.
So I setup anaconda2 and created a new python env within it. I check the python version.
python --version gives
Python 2.7.15 :: Anaconda, Inc..
I then go to the pytorch page and generate the
conda install command using
Python 2.7 and
CUDA 8 as parameters. The command is
conda install pytorch torchvision -c pytorch. After executing the command, I see that the python version has changed to 3.6 and
which python is now pointing to the python within the newly created env.
TLDR; I can’t seem to have pytorch installed with python 2.7. Can some one help me navigate through this?
An observation: changing between python version to generate the
conda install command on the pytorch home page does not change anything in the command. Not sure if anaconda will automatically decipher the python version that it should use? In any case, that does not seem to be working in my case.
Could you try to activate your environment and run
conda install --name myenv pytorch torchvision -c pytorch
@ptrblck, it says, “All packages are already installed” . I guess the problem is, the
conda install commands always install PyTorch with Py3.6. What should I change in the
conda install command so that I can install PyTorch with Py2.7 and not Py3.6?
I think your python2 environment shouldn’t even have python3.
Could you activate the env, call
python, and call:
It should point to something like:
@ptrblck, sorry for the delayed response.
I do a fresh login:
Python 2.7.15 :: Anaconda, Inc.
Then I source the environment:
source activate py2pytorch
Then the status is:
Python 3.6.5 :: Anaconda, Inc.
I also did as you asked:
So the environment inside anaconda2 is python 3.6 ?!
Thanks again !
Thanks for the update!
It looks like your default anaconda installation ships with Python2.7.
The environment you’ve created uses Python3.6.
If you would like to install PyTorch for Python2.7, you could either install it in the default environment or create a new environment with Python2.7:
conda create -n py27 python=2.7