问题
This is my first post here. I tried to find an answer to this question but to no avail.
Just installed Anaconda2 (2.7.11 Python kernel) on my Win10 machine. I am trying to learn the conda command. Here is my problem.
- I go to the Anaconda prompt window.
- I create a virtual environmant with
conda create -n myenv python=3.4
command. - I activate the environment with
activate myenv
. - When I list the environmants with
conda env list
it shows as active (star next to it). - When I start python from a command line it shows me that it is running 3.4.
- The same with ipython.
- When I type spyder it opens the spyder window but shows me 2.7.11. This is confirmed by running
print(sys.version)
.
Am I doing anything wrong or is this just windows 10 problem.
Thanks in advance, Andy
回答1:
When you type spyder
, the search for this command begins in the paths that the conda environment created. If it cannot find it there, it will go and search at other places. In your case in the paths of the default Anaconda install. So after you activate your environment:
activate myenv
you need to install sypder
inside this environment:
(myenv) conda install spyder
where (myenv)
indicates the active environment.
回答2:
Change the Python interpreter in the Preference menu. See pic below.
回答3:
Note: using Windows 10.
To use Spyder in a particular environment, there are at least two options:
- conda install spyder into that environment - the problem, for me, is that it also wants to install a large number of other packages that I don't want or need in that environment.
I just want to use Spyder for interactive programming/investigation using the particular packages that I have chosen to install in a particular environment. The solution to this is option 2.
Note: I installed Anaconda initially and so have Spyder in the Anaconda environment.
- Copy the relevant Spyder files from the Anaconda environment into the particular environment(s) you want to use Spyder in:
From: C:\Users\User\Anaconda\Lib\site-packages
Copy: spyderlib & spyderplugins Folders
To: C:\Users\User\Anaconda\envs\[Environment_Name]\Lib\site-packages
From: C:\Users\User\Anaconda\Scripts
Copy: spyder.exe, spyder.ico, spyder_light.ico & spyder-script.py Files
To: C:\Users\User\Anaconda\envs\[Environment_Name]\Scripts
To use Spyder in the desired environment:
- Activate the environment
- (Environment_Name) prompt> spyder
This works for me!
回答4:
you just have to write
conda create -n myenv python=3.4 spyder
conda activate myenv
spyder
and for deactivation later on ..
conda deactivate
来源:https://stackoverflow.com/questions/34217175/spyder-does-not-run-in-anaconda-virtual-environment-on-windows-10