C
C
citizen4042019-07-18 15:16:10
Python
citizen404, 2019-07-18 15:16:10

What is the difference between "pyenv local someEnvName" and "pyenv virtualenv activate someEnvName" commands???

People, tell me how to work with Python virtual environments pyenv + pyenv-virtualenv ?
I can't fully understand the difference between the commands :
- pyenv local someEnvName
- pyenv global someEnvName

on the one hand, and :
- pyenv activate someEnvName
on the other.
That is, I seem to understand their purpose separately, but there is no complete picture of the entire process of administering virtual environments ...
As I understand it:
pyenv local someEnvName - sets up a virtual environment with the name someEnvName for a specific directory (???)
pyenv global someEnvName - installs a virtual environment named someEnvName for the entire operating system (???)
pyenv activate someEnvName - activates/sets up a virtual environment named someEnvName for....What??? A specific directory or...?
For clarity, I will give my step-by-step sequence of actions.
STEP #1 . Create a directory (folder) for a new Python project.
5d3059d348c54949952477.png
STEP #2 . View all available versions of the Python interpreter installed using the pyenv utility
5d3059ee201a0552098334.png
STEP #3 . Creation of a new virtual environment for the project based on the selected version of the interpreter.
5d305faec1ef9757890409.png
STEP #4 . Installing (activating) the virtual environment
5d3060ba91228183047158.png
And here I have a dilemma, which command to use pyenv local newPythonProjectEnv orpyenv activate newPythonProjectEnv ???
As a result, I am confused by the fact that the terminal displays two pairs of parentheses before the start of the command line. In one - the name of the virtual environment I need, and in the other - the name of the virtual environment installed by default for the entire system. BUT, importantly, when I type pip3 list , the terminal shows ALL downloaded packages on a system wide basis, i.e. for the virtual environment named base , although I expected to see an empty list for newPythonProjectEnv .
What am I doing wrong ? Help me to understand.
If possible, describe the correct step-by-step workflow for working with Python virtual environments.
ps And another question, why when I enter the pyton --version command into the terminal I get
:
5d305aef82505842363617.png
, and when I enter pyton3 --version it shows:
5d305ae2a9293923417792.png
although neither one nor the other version of the interpreter appears in the list that is displayed after the pyenv versions command :
5d305b072b84a201411687.png
p.s.s. Do not judge strictly, I'm just learning. Just in case, below is the entire log of my actions in the terminal. I will be glad to any constructive criticism, advice, useful link.

TERMINAL LOG
(base) ➜ Видеокурс python --version
Python 2.7.15+
(base) ➜ Видеокурс python3 --version
Python 3.6.8
(base) ➜ Видеокурс pyenv local
pyenv: no local version configured for this directory
(base) ➜ Видеокурс pyenv global
3.7.3
(base) ➜ Видеокурс pyenv versions
system
2.7.16
2.7.16/envs/myNewVenv-2.7.16
3.4.4
* 3.7.3 (set by /home/neon/.pyenv/version)
3.7.3/envs/myNewVenv-3.7.3
3.7.3/envs/webscraping-3.7.3
anaconda3-2019.03
anaconda3-2019.03/envs/headfirst
anaconda3-2019.03/envs/marklutc-books
anaconda3-2019.03/envs/python-spec-lvl1
anaconda3-2019.03/envs/tceh-course
myNewVenv-2.7.16
myNewVenv-3.7.3
webscraping-3.7.3
(base) ➜ Видеокурс pyenv virtualenvs
2.7.16/envs/myNewVenv-2.7.16 (created from /home/neon/.pyenv/versions/2.7.16)
3.7.3/envs/myNewVenv-3.7.3 (created from /home/neon/.pyenv/versions/3.7.3)
3.7.3/envs/webscraping-3.7.3 (created from /home/neon/.pyenv/versions/3.7.3)
anaconda3-2019.03 (created from /home/neon/.pyenv/versions/anaconda3-2019.03)
anaconda3-2019.03/envs/headfirst (created from /home/neon/.pyenv/versions/anaconda3-2019.03)
anaconda3-2019.03/envs/marklutc-books (created from /home/neon/.pyenv/versions/anaconda3-2019.03)
anaconda3-2019.03/envs/python-spec-lvl1 (created from /home/neon/.pyenv/versions/anaconda3-2019.03)
anaconda3-2019.03/envs/tceh-course (created from /home/neon/.pyenv/versions/anaconda3-2019.03)
myNewVenv-2.7.16 (created from /home/neon/.pyenv/versions/2.7.16)
myNewVenv-3.7.3 (created from /home/neon/.pyenv/versions/3.7.3)
webscraping-3.7.3 (created from /home/neon/.pyenv/versions/3.7.3)
(base) ➜ Видеокурс mkdir newPythonProject && cd newPythonProject
(base) ➜ newPythonProject pyenv virtualenv 3.4.4 newPythonProjectEnv
Ignoring indexes: https://pypi.python.org/simple
Requirement already satisfied (use --upgrade to upgrade): setuptools in /home/neon/.pyenv/versions/3.4.4/envs/newPythonProjectEnv/lib/python3.4/site-packages
Requirement already satisfied (use --upgrade to upgrade): pip in /home/neon/.pyenv/versions/3.4.4/envs/newPythonProjectEnv/lib/python3.4/site-packages

(base) ➜ newPythonProject pyenv versions
system
2.7.16
2.7.16/envs/myNewVenv-2.7.16
3.4.4
3.4.4/envs/newPythonProjectEnv
* 3.7.3 (set by /home/neon/.pyenv/version)
3.7.3/envs/myNewVenv-3.7.3
3.7.3/envs/webscraping-3.7.3
anaconda3-2019.03
anaconda3-2019.03/envs/headfirst
anaconda3-2019.03/envs/marklutc-books
anaconda3-2019.03/envs/python-spec-lvl1
anaconda3-2019.03/envs/tceh-course
myNewVenv-2.7.16
myNewVenv-3.7.3
newPythonProjectEnv
webscraping-3.7.3
(base) ➜ newPythonProject pyenv local newPythonProjectEnv
(newPythonProjectEnv) (base) ➜ newPythonProject pyenv local
newPythonProjectEnv
(newPythonProjectEnv) (base) ➜ newPythonProject pip3 list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
apturl (0.5.2)
argcomplete (1.8.1)
asn1crypto (0.24.0)
astroid (2.2.5)
beautifulsoup4 (4.6.0)
Brlapi (0.6.6)
certifi (2018.1.18)
chardet (3.0.4)
command-not-found (0.3)
cryptography (2.1.4)
cupshelpers (1.0)
Cython (0.29.2)
defer (1.0.6)
distro-info (0.18ubuntu0.18.04.1)
galternatives (0.92.2)
html5lib (0.999999999)
httplib2 (0.9.2)
idna (2.6)
isort (4.3.21)
jedi (0.11.1)
keyring (10.6.0)
keyrings.alt (3.0)
language-selector (0.1)
launchpadlib (1.10.6)
lazr.restfulclient (0.13.5)
lazr.uri (1.0.3)
lazy-object-proxy (1.4.1)
louis (3.5.0)
lxml (4.2.1)
macaroonbakery (1.1.3)
Mako (1.0.7)
MarkupSafe (1.0)
mccabe (0.6.1)
netifaces (0.10.4)
oauth (1.0.1)
olefile (0.45.1)
parso (0.1.1)
pexpect (4.2.1)
Photohash (0.4.1)
Pillow (5.3.0)
pip (9.0.1)
progressbar (2.3)
protobuf (3.0.0)
psutil (5.4.8)
pycairo (1.16.2)
pycrypto (2.6.1)
pycups (1.9.73)
pygobject (3.26.1)
pylint (2.3.1)
pymacaroons (0.13.0)
PyNaCl (1.1.2)
pyRFC3339 (1.0)
python-apt (1.6.4)
python-chess (0.24.1)
python-dateutil (2.6.1)
python-debian (0.1.32)
python-gnupg (0.4.1)
pytz (2018.3)
pyxattr (0.6.0)
pyxdg (0.25)
PyYAML (3.12)
reportlab (3.4.0)
requests (2.18.4)
requests-unixsocket (0.1.5)
scandir (1.9.0)
scour (0.36)
screen-resolution-extra (0.0.0)
SecretStorage (2.3.1)
setuptools (40.6.3)
simplejson (3.13.2)
six (1.12.0)
speedtest-cli (2.1.1)
system-service (0.3)
systemd-python (234)
thonny (2.1.16)
typed-ast (1.4.0)
ubuntu-drivers-common (0.0.0)
Ubuntu-Make (18.5)
ufw (0.36)
unattended-upgrades (0.1)
urllib3 (1.22)
usb-creator (0.3.3)
virtualenv (16.6.2)
wadllib (1.3.2)
webencodings (0.5)
wheel (0.30.0)
wrapt (1.11.2)
xkit (0.0.0)
youtube-dl (2019.6.8)
zope.interface (4.3.2)


DO NOT OPEN!!!
Огромное спасибо тебе, человек, прочитавший мою простыню до конца)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Guest007, 2019-07-18
@Guest007

In the case of local, you set a specific interpreter (wirth) for the current directory (and sub-directories).
When this happens, including its activation. Subsequently, this environment will be activated automatically when you enter this or a subdirectory. It's just cd ~/prg/my_cool_projectthat you have already activated the environment.
If you didn't do local (or not in the current directory), but want to use some of your virtual - do activate and work.
global - not for the whole system, of course, but for you as a user, by default. System change.
local in specific directories will override this.
all this, of course, makes sense after the creation of Wirth pyenv virtualenv 3.7.3 MyCoolVertualEnv. Creating a virtual does not activate it, you need to manually activate or local

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question