Spyder: cannot run spyder in a conda virtual environment for specific settings

Created on 23 Sep 2018  路  14Comments  路  Source: spyder-ide/spyder

im using ubuntu 16.04 and anaconda 3.
Python 3.6.6 64bits, Qt 5.9.6, PyQt5 5.9.2 on Linux
I am using Spyder 3.3.1 ,

I created an virtual environment via conda (conda create -n PyTorch_0.3
) and inside that i installed a pytorch version (pytorch 0.3) that i want for a specific project . I also have the newest version of pytorch (pytorch 0.4.1) outside of my virtual environment .

Now I activate my virtuan env and go there and run spyder in that terminal, but when i check the version of pytorch there it still shows that it is using the newest pytorch not the version that i have inside that virtual env.
Can you please help what should i do to use the version that i installed inside the virtual env?

in other words, when i check the version in the terminal it shows it okay:
image

but when i open spyder:
image

and check the version it does not match:

image

Thanks

Awaiting Followup

Most helpful comment

Did you install Spyder in your virtualenv too? Because if not, you're starting your system Spyder.

All 14 comments

@ccordoba12 do you have any suggestion?

You probably have other Python interpreter selected in

Tools > Preferences > Python interpreter

That's why you're not getting the result you expect.

it is like this:
image

should i change it to "USe the follwoing Python interpreter" "? what should i do in the path if i change to this option?

I read it.
I am doing pretty much as it said. the difference is that, for models like keras, we can install the version that we want when creating thevirtual environment but for pytorch we cannot, so i installed it separately inside the virtual environment, when check it in the virtual environment it works, but in spyder is not. i m not sure why it happens :/

Please give us a step by description of how you're creating your virtualenv, so we can test the process in our side.

i mentioned the details on the first comments.
please let me know if it is not clear

I also have the newest version of pytorch (pytorch 0.4.1) outside of my virtual environment .

Where do you have it? Is it in another virtualenv? If not, then you're really asking for problems if you're messing with your system Python, i.e. the Python version provided by your Linux distro. And that's because you should ever, ever touch your system Python or you can break your OS entirely (the same goes for macOS).

I have Pytorch 0.4.1 in my main system, no virtual environment is used for that. then i have a virtual env for pytorch 0.3.
It has nothing to do with python i guess, it is PyTorch not Python.
The python is the same for both of them

I have Pytorch 0.4.1 in my main system

As I said, that's a bad idea. What happens if you remove that package and try again?

but it works fine when i use terminal and run a code in the terminal.
i can try to remove it and see what happens

Did you install Spyder in your virtualenv too? Because if not, you're starting your system Spyder.

no it was already installed via anaconda, do you think i should reintall it in the virtual env?

Of course because if not the Spyder that starts with spyder in the command line is the one in your root environment (and that's the environment with PyTorch 0.4).

This is documented documented in the guide you said you already read:

https://github.com/spyder-ide/spyder/wiki/Working-with-packages-and-environments-in-Spyder#the-naive-approach

Please don't make us waste time for next time.

Was this page helpful?
0 / 5 - 0 ratings