Answer the question
In order to leave comments, you need to log in
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.
STEP #2 . View all available versions of the Python interpreter installed using the pyenv utility
STEP #3 . Creation of a new virtual environment for the project based on the selected version of the interpreter.
STEP #4 . Installing (activating) the virtual environment
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
:
, and when I enter pyton3 --version it shows:
although neither one nor the other version of the interpreter appears in the list that is displayed after the pyenv versions command :
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.
Answer the question
In order to leave comments, you need to log in
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_project
that 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 questionAsk a Question
731 491 924 answers to any question