Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
paths for venv
#1
i'm looking for documentation that describes all the various paths used by venv needed to understand how venv might impact the system. this would be needed by the system administrator.

if you are tempted to ask why i need this information, start a new thread in the bar and ask there.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
Python's venv is just a self contain folder with python and pip executable in sub-folder bin.
Make can call it what ever you want i always use _env end so i know that folder is a environment.
tom@tom:~$ python -m venv req_env
tom@tom:~$ cd req_env/
tom@tom:~/req_env$ source bin/activate

# Placement of python and pip
(req_env) tom@tom:~/req_env$ which python
/home/tom/req_env/bin/python
req_env) tom@tom-:~/req_env$ which pip
/home/tom/req_env/bin/pip
Install something.
(req_env) tom@tom:~/req_env$ pip install requests
Collecting requests
  Downloading requests-2.28.0-py3-none-any.whl (62 kB)
     |████████████████████████████████| 62 kB 628 kB/s 
Collecting certifi>=2017.4.17
  Downloading certifi-2022.5.18.1-py3-none-any.whl (155 kB)
     |████████████████████████████████| 155 kB 3.0 MB/s 
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.9-py2.py3-none-any.whl (138 kB)
     |████████████████████████████████| 138 kB 4.8 MB/s 
Collecting charset-normalizer~=2.0.0
  Downloading charset_normalizer-2.0.12-py3-none-any.whl (39 kB)
Collecting idna<4,>=2.5
  Downloading idna-3.3-py3-none-any.whl (61 kB)
     |████████████████████████████████| 61 kB 2.8 MB/s 
Installing collected packages: urllib3, idna, charset-normalizer, certifi, requests
Successfully installed certifi-2022.5.18.1 charset-normalizer-2.0.12 idna-3.3 requests-2.28.0 urllib3-1.26.9

(req_env) tom@tom:~/req_env$ pip list
Package            Version
------------------ -----------
certifi            2022.5.18.1
charset-normalizer 2.0.12
idna               3.3
pip                21.2.4
requests           2.28.0
setuptools         58.1.0
urllib3            1.26.9
Delete the req_env folder and all traces of environment is gone.
tom@tom:~$ rm -r req_env
Reply
#3
so if you are cd'd into your venv directory, pip and python know that it is a venv directory, such as because something special is in there? does a user need to own it (all) or can 2 different users share the same venv (assuming they work all the sharing issues) directory? do i just run the python command here or do i have to tell it, unless it's in the venv directory?

where is the python engine for it stored? within?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#4
(Jun-13-2022, 12:23 AM)Skaperen Wrote: so if you are cd'd into your venv directory, pip and python know that it is a venv directory, such as because something special is in there?
No it's the activate that dos it,you see it become (req_env) then can cd to whatever directory and will always use python/pip from that environment as long is activated (req_env).
Quote:or can 2 different users share the same venv (assuming they work all the sharing issues) directory?
Yes they can work on with same environment,it's nothing specials just a Python version that isolated from OS Python version or other environment.
Quote:do i just run the python command here or do i have to tell it, unless it's in the venv directory?
When the environment is not active deactivate and would use it like a editor most point to the Python interpreter in bin folder,and not the OS Python.
/home/tom/req_env/bin/python
Virtual environment is very common work flow in Python,so editor like eg VS Code, PyCharm pick up environment automatically or have easy way to choose it.
Reply
#5
(Jun-13-2022, 01:18 AM)snippsat Wrote:
Quote:so if you are cd'd into your venv directory, pip and python know that it is a venv directory, such as because something special is in there?
No it's the activate that dos it,you see it become (req_env) then can cd to whatever directory and will always use python/pip from that environment as long is activated (req_env).
in terms of paths being checked by an outsider program, how can it know if that directory is a python virtual environment or not. i was hoping it might be as simple as there being a file, sub directory, or symlink, of a particular name pattern in there somewhere to test existence or mode.

can one script be run in one terminal window in one environment and while that is still running a script be run in a different terminal window (different shell) in a different environment with both being cd'd in the same working directory (such as home directory) at the same time?

(Jun-13-2022, 01:18 AM)snippsat Wrote: Virtual environment is very common work flow in Python,so editor like eg VS Code, PyCharm pick up environment automatically or have easy way to choose it.

will my editors pick up on it? i have a big wrapper around emacs as well as several commands that carry out common changes i do at the shell command level. most, but not all, of these are in Python, one is in bash plus awk.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#6
(Jun-13-2022, 10:06 PM) Wrote: in terms of paths being checked by an outsider program, how can it know if that directory is a python virtual environment or not
As mention can name it to whatever you want i always end with env somthing_env,can organize under top folder i use div_code where i have lot Python stuff mess together.
Skaperen Wrote:can one script be run in one terminal window in one environment and while that is still running a script be run in a different terminal window (different shell) in a different environment with both being cd'd in the same working directory (such as home directory) at the same time?
Yes
Skaperen Wrote:will my editors pick up on it? i have a big wrapper around emacs as well as several commands that carry out common changes i do at the shell command level. most, but not all, of these are in Python, one is in bash plus awk.
Most editors can choose what Python interpreter to use,sometime when use vim i just drop into bin folder then will use python that is there.
Also pip-tools and Poetry(really good),is tools to look into that dos do more that simple venv.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  The command python3 -m venv venv does not correctly set sys.path echeadle 2 2,649 Jul-25-2023, 10:41 AM
Last Post: Aften1961
Question Emacs 28 and venv pisterpesto 1 1,869 Nov-30-2022, 05:55 AM
Last Post: Larz60+
  check for duplicate file paths Skaperen 4 1,242 Jun-21-2022, 06:29 AM
Last Post: Gribouillis
  venv conflict at shell prompt Skaperen 3 2,823 Feb-21-2019, 02:18 AM
Last Post: Larz60+
  PyCharm virtual environment (venv) issues? j.crater 1 2,255 Aug-14-2018, 10:22 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020