Reputation: 9927
I am a ruby programmer trying to learn python. I am pretty familiar with pyenv since it is like a copy and paste from rbenv. Pyenv helps allow to have more than one version of python in a system and also to isolate the python without touching sensitive parts of system.
I suppose every python installation comes with pip package. What I still don't understand is, there are many good python libs out there that suggest to use this virtualenv and anaconda. I can even find a virtualenv plugin for pyenv.
Now I am getting confused with the purpose of these two pyenv and virtualenv. worse inside pyenv there is a virtualenv plugin.
My questions are:
Your explanation with example will be highly appreciated.
Upvotes: 276
Views: 159943
Reputation: 4140
Edit: It's worth mentioning pip
here as well, as conda
and pip
have similarities and differences that are relevant to this topic.
pip: the Python Package Manager.
pip
as the python equivalent of the ruby gem
commandpip
is not included with python by default.brew install python
sudo easy_install pip
gemfile
pip freeze > requirements.txt
pyenv: Python Version Manager
pyenv
lets you manage this easily.virtualenv: Python Environment Manager.
virtualenv
, simply invoke virtualenv ENV
, where ENV
is is a directory to place the new virtual environment.virtualenv
, you need to source ENV/bin/activate
. To stop using, simply call deactivate
.virtualenv
, you might install all of a workspace's package requirements by running pip install -r
against the project's requirements.txt
file.Anaconda: Package Manager + Python Version Manager + Environment Manager + Additional Scientific Libraries.
conda install <packagename>
miniconda
version, which seems like it could be a more simple option than using pip
+ virtualenv
, although I don't have experience using it personally.conda
allows you to install packages, these packages are separate than PyPI packages, so you may still need to use pip additionally depending on the types of packages you need to install.See also:
Upvotes: 269
Reputation: 1869
Simple explanation: https://docs.conda.io/projects/conda/en/latest/commands.html#conda-vs-pip-vs-virtualenv-commands
If you have used pip and virtualenv in the past, you can use conda to perform all of the same operations.
Upvotes: 5
Reputation: 9927
Simple analogy:
Since I use python3 I prefer the python3 built-in virtual environment named venv. venv is simple and easy to use. I would recommend you to read its official docs. The doc is short and concise.
In ruby, we don't really need a virtual environment because the bundler takes care of it. Both virtual env and bundler are great, however, they have different solutions to solve the same problem.
Upvotes: 10