I created a conda environment called testenv
in Windows 10 that contains Python 3.6 and Spyder. I also installed Selenium using the method described in this answer. I checked that these packages are installed with
conda list -n testenv
To run Spyder in that environment I followed the instructions in this answer and its related comments. So I activated the environment with
activate testenv
which modified the prompt to indicate that testenv
is active. Then I typed
spyder
to launch Spyder. (When Spyder opens, my command window automatically closes, and if I open another one without closing Spyder, and I issue the command conda info -e
, the output indicates that testenv
is no longer active.) At this point, when I run code within Spyder that contains the line
from selenium import webdriver
the Spyder console reports
ModuleNotFoundError: No module named 'selenium'
My questions are:
Is Spyder really running in testenv
? If so, why is this error being reported? If not, what am I doing wrong?
EDIT: Further research turned up the aptly-named thread "Spyder does not run in Anaconda virtual environment on Windows 10". I followed the suggestion, in the accepted answer, of installing Spyder after activating the environment, but that just returned the message
# All requested packages already installed.
# packages in environment at C:Anaconda3envsestenv:
#
spyder 3.2.2 py36_0
One of that answer's comments suggests using where spyder
within the active environment to check which executables are available. This returned
C:Anaconda3Scriptsspyder.exe
C:Anaconda3envsestenvScriptsspyder.exe
So I tried starting Spyder by typing the full path of the second entry. Spyder opened, and my program ran without errors. This seems to have solved the problem.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…