How to use poweshell in visual studio code change conda virtual enviroment - powershell

I use conda create a virtual environment, when I want to use vs code to change my virtual environment by typing "conda activate PyTorch" in terminal, it doesn't work, and I found a solution that changes PowerShell to CMD and typing the instrument "conda activate PyTorch", and it succeeds, and I wondering why Powershell can't work and cmd can work,and the another question is how to setting so that PowerShell have same ability to change the virtual environment.

Related

Change terminal used by Code-Runner extension in VS Code to cmd while workspace default integrated terminal is powershell?

Is there a setting in VS Code for the Code Runner extension that lets you run in a shell that's different than the workspace's default shell?
For context, my default integrated terminal is powershell. I have the code-runner.runInTerminal setting set (see, e.g., here), and whenever I run python using the extension, it creates a new "Code" powershell integrated terminal (unless one already exists), activates my selected python environment, and runs the code. However, when it tries to activate the environment, I get this popup:
So, I'd like to change the shell that Code Runner uses to cmd, BUT I want to keep using powershell as my default integrated terminal for the workspace.
Changing my workspace's default shell to cmd isn't an option, and neither is changing to a third shell like WSL. This issue indicates to me that the environment activation isn't getting fixed in powershell anytime soon. For now, I've done what the issue suggests and have just stopped Code Runner from activating a new environment in the terminals it creates (set python.terminal.activateEnvironment to false), but I'm worried now I won't be able to have Code Runner use any other python environments than the default one. What can I do?

Unable to activate virtual environment on visual studio code

I am using virtualenv to create a virtual environment. I am able to activate the virtual environment on the command prompt but when i try to do the same on visual studio code , it says "Could not find conda environment: Test
You can list all discoverable environments with conda info --envs.".
It is trying to find a anaconda environment inspite of me using a global python interpreter.
When I use "activate env_name", how do i make it to search and activate a virtual environment outside anaconda. I am using windows 10.
.

How can i identify different terminal instances in VsCode

I am using VsCode Remote with Linux, and when starting a VsCode integrated terminal in the IDE, I need to run some scripts in the remote server. I would therefore like to identify "which" of my integrated terminals is calling the script. Is there any way to identify the concrete terminal instance from the script in the remote machine? (For example, environment variable containing the name of the terminal, etc...)

PowerShell Opening File instead of Running When in Python Virtual Environment

I am using Python 3.9.9 (installed via MSYS2) and Windows PowerShell on Windows 10 64-bit. I am trying to learn more about Python's virtual environment.
I was able to initialize and activate virtual environment using the respective commands in PowerShell.
python3 -m venv .venv
.\.venv\bin\Activate.ps1
I notice that before activating the virtual environment, python --version would work as expected and output the Python version installed. However, once virtual environment has been activated, the same command would prompt Windows to open a file (window below would pop up).
Window's reaction when in virtual environment
I know the virtual environment was activated because I could see (.venv) being displayed.
Is this expected behavior? What should I do for python commands to still work in virtual environments? Thank you for your help!

How to activate virtual environment in VS Code terminal for windows?

I'm using windows OS and in terminal (cmd) I created a virtual
environment for Django and given name as 'test'. Now I just installed
Visual Studio code now how to activate the virtual environment 'test'
in VS Code.
After moving to the project path in Pycharm just type "workon test" test will be the environment name that's it it will be done. Please update your pycharm even if you type the above command.