Give full Path,quick example.
# Make
λ python -m venv pq_env
# Cd in
G:\div_code
λ cd pq_env\
# Activate with absolute path
G:\div_code\pq_env
λ G:\div_code\pq_env\Scripts\activate.bat
# Test pip,shall point to this folder
(pq_env) G:\div_code\pq_env
λ pip -V
pip 22.0.4 from G:\div_code\pq_env\lib\site-packages\pip (python 3.10)
(pq_env) G:\div_code\pq_env
env\Scripts\activate.bat assumes env is a subfolder of the current folder. If you type dir<enter> you should see something like:
Output:
03/03/2022 03:03 PM <DIR> .
03/03/2022 03:03 PM <DIR> ..
02/08/2022 06:25 PM <DIR> env
04/13/2022 01:17 PM <DIR> windows64
If you type dir env <enter> you should see.
Output:
02/08/2022 06:25 PM <DIR> .
02/08/2022 06:25 PM <DIR> ..
02/08/2022 06:25 PM 42 .gitignore
02/08/2022 06:25 PM <DIR> Lib
02/08/2022 06:25 PM 264 pyvenv.cfg
03/07/2022 03:20 PM <DIR> Scripts
And if you type dir env\Scripts you should see
Output:
03/07/2022 03:20 PM <DIR> .
03/07/2022 03:20 PM <DIR> ..
02/08/2022 06:25 PM 2,148 activate
02/08/2022 06:25 PM 1,021 activate.bat
02/08/2022 06:25 PM 3,071 activate.fish
02/08/2022 06:25 PM 1,755 activate.ps1
02/08/2022 06:25 PM 1,162 activate.xsh
02/08/2022 06:25 PM 1,193 activate_this.py
02/08/2022 06:28 PM 106,360 cmake_pprint.exe
02/08/2022 06:25 PM 510 deactivate.bat
02/08/2022 06:25 PM 106,358 pip-3.9.exe
02/08/2022 06:25 PM 106,358 pip.exe
02/08/2022 06:25 PM 106,358 pip3.9.exe
02/08/2022 06:25 PM 106,358 pip3.exe
02/08/2022 06:25 PM 24 pydoc.bat
03/07/2022 01:45 PM 106,362 pyproject-build.exe
02/08/2022 06:25 PM 535,056 python.exe
02/08/2022 06:25 PM 534,544 pythonw.exe
03/07/2022 03:20 PM 106,348 uvicorn.exe
02/08/2022 06:25 PM 106,345 wheel-3.9.exe
02/08/2022 06:25 PM 106,345 wheel.exe
02/08/2022 06:25 PM 106,345 wheel3.9.exe
02/08/2022 06:25 PM 106,345 wheel3.exe
I don't have a 'env' directory, just a 'venv' one.
dir
produces this list :
Volume in drive C has no label.
Volume Serial Number is B475-2996
Directory of C:\Users\GreenBus
14/04/2022 00:18 <DIR> .
14/04/2022 00:18 <DIR> ..
11/04/2022 01:24 <DIR> .atom
28/01/2022 20:27 <DIR> .cache
09/04/2022 18:56 <DIR> .dbus-keyrings
13/04/2022 18:52 <DIR> .designer
28/01/2022 20:09 <DIR> .eclipse
11/04/2022 01:42 <DIR> .idlerc
06/12/2021 02:56 <DIR> .Origin
14/04/2022 18:12 <DIR> .p2
11/04/2022 20:03 3,186 .pagerc
06/12/2021 02:56 <DIR> .QtWebEngineProcess
15/11/2021 18:46 <DIR> 3D Objects
25/01/2022 00:27 <DIR> ansel
14/04/2022 00:18 <JUNCTION> Box [\??\Volume{070790e4-b7a1-11ec-b1ef-2cf05dd29584}\]
15/11/2021 18:46 <DIR> Contacts
14/04/2022 00:19 <DIR> Creative Cloud Files
14/04/2022 17:53 <DIR> Desktop
13/04/2022 20:34 <DIR> Documents
14/04/2022 17:53 <DIR> Downloads
28/01/2022 20:55 <DIR> eclipse
28/01/2022 20:54 <DIR> eclipse-workspace
31/01/2022 20:37 <DIR> Favorites
15/11/2021 18:46 <DIR> Links
15/11/2021 18:46 <DIR> Music
02/02/2022 22:47 994 New document 1.2022_02_02_21_47_34.0.svg
11/04/2022 01:45 <DIR> OneDrive
15/11/2021 18:47 <DIR> Pictures
25/01/2022 01:13 <DIR> Saved Games
15/11/2021 18:47 <DIR> Searches
12/04/2022 18:09 <DIR> venv
14/04/2022 00:18 <DIR> Videos
2 File(s) 4,180 bytes
30 Dir(s) 192,383,741,952 bytes free
dir C:\Users\GreenBus\venv\Scripts
...shows the activate.bat file. When I run it, I get the following :
(venv) C:\Users\GreenBus\venv\Scripts>
Does the current directory get used as the virtual directory? Can I set it to my work directory, sorry I'm clueless...I'm going to investigate.
(Apr-14-2022, 05:39 PM)davediamond Wrote: [ -> ]...shows the activate.bat file. When I run it, I get the following :
Then is activated test pip,but just follow my commands and give it better name as eg
pq_env
(my fist command make this folder).
I use
cmder in demo.but commands is just the same in cmd or Poweshell.
(Apr-14-2022, 05:16 PM)snippsat Wrote: [ -> ]Give full Path,quick example.
# Make
λ python -m venv pq_env
# Cd in
G:\div_code
λ cd pq_env\
# Activate with absolute path
G:\div_code\pq_env
λ G:\div_code\pq_env\Scripts\activate.bat
# Test pip,shall point to this folder
(pq_env) G:\div_code\pq_env
λ pip -V
pip 22.0.4 from G:\div_code\pq_env\lib\site-packages\pip (python 3.10)
(pq_env) G:\div_code\pq_env
G:\div_code
< what is the purpose of this directory? Just so I know. I've not written batch files in .cmd before. Is this where you put all your Python modules?
(Apr-14-2022, 06:26 PM)davediamond Wrote: [ -> ]< what is the purpose of this directory? Just so I know. I've not written batch files in .cmd before. Is this where you put all your Python modules?
It's just folder that i have made where have my python files/folders.
So it's has nothing to with batch files,it's just a ordinary folder folder you can make your own.
So when start in this folder then commands shown will make a new sub-folder there called pq_env.
I put my virtual environment in the root directory of the project I am working on. If you are using pycharm or vscode (or probably any of the IDE's) it doesn't matter where you put the virtual environment because they remember where it is.
If you named your virtual environement venv, then you would type "venv\Scripts\activate" to run it. I find in Windows that you don't have to type the .bat. You also don't have to worry about upper/lower case because windows doesn't care.
I now have the following running on my pc :
(pq_env) C:\Users\GreenBus\myPython\pq_env>
Now you just have to make sure you are running your virtual environment whenever you install any Python packages.