When I use bash script to create Python virtual environment, all environment (interpreter, pip and other packages) are system-wide packages.
#!/bin/bash
virtualenv <venv name> --python python3
I check it via the following commands:
which python3
which pip3
and
pip3 list
However, if I type the command manually, it works. I got an isolated environment.
Can someone tell me why it happens and how to use scripts to create Python virtual environments? (Because I want to make it automatic via scripts). Thanks a lot.
NOTE:
I am not trying to activate the environment in the wrong way. I do use source
to activate it and get the mark in the head of my command line. I am asking about why creating the virtual environment in a bash script will not copy the binary file of interpreter and pip !!! That will miss the point to use a virtual environment !!! And to my understanding, no matter in which bash session (the current one or the subprocess) I execute the creating command, the result should be the same. That is the problem.