paths for venv - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: General (https://python-forum.io/forum-1.html) +--- Forum: News and Discussions (https://python-forum.io/forum-31.html) +--- Thread: paths for venv (/thread-37450.html) |
paths for venv - Skaperen - Jun-11-2022 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. RE: paths for venv - snippsat - Jun-11-2022 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/pipInstall 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.9Delete the req_env folder and all traces of environment is gone.tom@tom:~$ rm -r req_env RE: paths for venv - Skaperen - Jun-13-2022 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? RE: paths for venv - snippsat - Jun-13-2022 (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/pythonVirtual 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. RE: paths for venv - Skaperen - Jun-13-2022 (Jun-13-2022, 01:18 AM)snippsat 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. 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.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). 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. RE: paths for venv - snippsat - Jun-14-2022 (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 notAs 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 .
|