Now, I have learned that using virtual environments for your project is nice, and I learned how to use built-in venv module with my python3.7 installation.
Suppose I have created a virtual environment with this path
~/Desktop/Project1/venv
Now, I know how to activate, deactive the virtual environment etc. However, what I could not figure out is, the next step.
I can create .py files in project folder and compile them using python script.py
of course, but using bash all the time is I suppose not the best way.
Assume I want to use sublime text to write and run my scripts, I could not figure out how I can make it possible.
I know how to change preferred python interpreter by adding a new build profile to sublime text.
It was pretty understandable when I was dealing with global python3.7 environment.
But I am confused how to implement this into this new virtual environment.
So, please provide me a solution to this.
Thanks.
If you can make your tools use the python
binary placed within the directory of your virtual environment, then you should be all set (no need to activate and desactivate the virtual environment). The full path should be something like:
/path/to/venv/bin/python
C:\path\to\venv\Scripts\python.exe
If everything is setup right the other Python executable scripts (such as pip, pylint, pep8, and so on) are also located in that same directory and can be used directly without activating the virtual environment. But as always I'd recommend using the executable modules instead of the scripts whenever possible (/path/to/venv/bin/python -m pip somecommand
instead of /path/to/venv/bin/pip somecommand
).
References: