PowerShell Opening File instead of Running When in Python Virtual Environment - powershell

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!

Related

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

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.

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.
.

Python virtual environments do nothing

I've recently tried to start using virtual environments but I cannot get them to work as they should.
When I activate a virtual environment, my python interpreter seems to ignore it completely, and continue using my global environment. It says that the packages that I've installed to my virtual environment do not exist and it continues to use my global packages. I've tried using virtualenv and venv and they both have the same problem. Am I supposed to have my project files in a certain location with respect to the virtual environment folder?
FYI, I am using Windows 10
My virtual environment was also using my global environment only (using system site programs and packages; Windows 10). I used commands virtualenv .env -p python3 and .env\Scripts\activate. I found out there is a problem with paths (%PATH%). VEnv was in echo %PATH% but when I tried where python or where pip, path for VEnv was not there. I had very long length and diacritics in my path. I moved the project to a new directory (short simple path), generated a new virtual environment, activated and eureka. Virtual environment works.

How to get the list of the python virtual environments installed on a linux server

I am new to linux environments. I have a linux server on which I have installed python3 in some virtual environment (but I no longer remember the name of the virtual environment). I know that if I were using anaconda on a windows computer, I would do the following to get the virtual environment names.
conda info --envs
The question is how do I get the list of all the virtual environments on my linux server and the path to those environments? In particular, I want a link to the bin folder containing my python3 so that I can activate my virtual environment.
Assuming you have created the virtual environments with the python pip install virtualenv command, run the command
$locate activate
It will list down all the folders having 'activate' in it. Among those you can find the virtual environment folders you created. Remember, the virtual env folders are of this form your_env_name/bin/activate under the parent folder where it was created.

Python kernel and jupyter extension

I am using vscode with the Python extension and Jupyter extension. For the Python extension, I have several interpreters available, installed by anaconda directly or different virtual environments I have created using conda. Thus, with the Python extension I can run code using different Python versions and packages. However, only one kernel is available for running the jupyter notebooks within vscode:
C:\ProgramData\Anaconda3\python.exe -m ipykernel_launcher
The "jupyter mode" in vscode does not recognize packages I have installed in my virtual environments. Is there a way to start the Python kernel for "jupyter mode" from one of my virtual environments? Or is there another way to solve this problem so that I can use a specific virtual environment in "jupyter mode" within vscode?
Thanks for all help.
The solution was to install the ipykernel for the different conda environments following instructions such as these. These kernels are then automatically identified by vscode.