简体   繁体   中英

Visual Studio Code Python Interactive Window env different from selected?

在此处输入图像描述 I am using visual studio code to try and replace the Spyder IDE. To replicate Spyder's variable explorer, I am trying to leverage VS code's Python Interactive Window.

Upon launching Vs Code, I select my environment using "Select Interpreter" and then picking the env. This then changes at the bottom of the application as expected.

However, when I then try and run my code in the interactive window it appears to reference a different environment? It also keeps telling me to install ipykernel.

Is this functioning correctly? I do see an option to change the env in the interactive window but that doesn't do anything.enter image description here

I found a similar question here But I have ipykernel installed in my environment so I'm not sure why it wouldn't notice that? Is there another dependency?

Maybe we can simplify the problem. Click top-right environment and changes it to which you want.

Start off by opening your Anaconda prompt and from there activate your virtual environment (type: conda activate my_env, replacing my_env with your environment name, and hit enter.) Then type the command: 'code', which will open up VS Code from within your active virtual environment. Before this approach, also check that your VS Code settings.json file has the python path set correctly to your environment installation. Now it should work. To see your install path: Anaconda is installed in your user home directory: Windows 10: C:\Users\\Anaconda3\

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM