pip and conda : where to use these - an overview

Einfach Dinge, die nichts mit XAMPP, Apache Friends, Apache, MySQL, PHP und alle dem zu tun haben. Allerlei halt. ;)

pip and conda : where to use these - an overview

Postby unleash_it » 01. April 2024 20:49

pip and conda - where to use each of these options?

ever wondered how where to use pip and where to use conda:

- pip is a package-manager for python packages.
- Conda on the other handside - it is a packaging tool and installer that aims to do more than what pip does; Yes - conda can do lots of other nice things too.

for example:
- it can also handle library dependencies outside of the Python packages as well as the Python packages themselves.
- it can create a virtual environment, like virtualenv does.

to sume up: Conda handles both Python and non-Python installation tasks. We also can have Conda packages for C libraries, or R packages, and many many more things - or simply: really anything.
long speech short sense: Conda is the package manager of Anaconda, but it can do lot more: it can be used outside of Anaconda too.

but the usage of Conda is interesting - but some developers use other tools: here some thoughts regarding the various tools:
well there are existing lots of tools that help us to manage virtual Python environments: Venv, pyenv, pipenv, poetry, and we have to mention here also Docker, and of course also virtualenv - and last but not least conda.

in the following we start with explanations on the different things: pip, PyPI, venv, pyenv, virtualenv, or any other....

let us start with pip:
pip: so what is pip. pip is just the Python Package Manager.
well, we might think of pip as the general python equivalent of the ruby gem command - it is pretty similar

- but wait: pip is not included with python by default.
we may install Python while using homebrew, which will install pip automatically: brew install python
besides this we can find and publish python packages using PyPI: The Python Package Index ( https://pypi.python.org/pypi )

pip: Python packages only: it compiles everything from source

from the docs:
Python Packaging User Guide ....[...]...the Python Packaging User Guide, a collection of tutorials and references to help you distribute and install Python packages with modern tools. This guide is maintained on GitHub by the Python Packaging Authority. We happily accept any contributions and feedback. ??
Get started
- Essential tools and concepts for working within the Python development ecosystem are covered in our Tutorials section:
- to learn how to install packages, see the tutorial on installing packages.
- to learn how to manage dependencies in a version controlled project, see the tutorial on managing application dependencies.
- to learn how to package and distribute our projects, see the tutorial on packaging and distributing
- to get an overview of packaging options for Python libraries and applications, see the Overview of Python Packaging.

The requirements.txt file is comparable to the ruby gemfile: To create a requirements text file, pip freeze > requirements.txt Note, at this point, we have python installed on our system, and we have created a requirements.txt file that outlines all of the python packages that have been installed on your system.

PyPI this packages is not in the standard library: virtualenv (see https://pypi.org/project/virtualenv/ ) is a very popular tool that creates isolated Python environments for Python libraries. It works by installing a bunch of files in a directory (eg: env/), and then modifying the PATH environment variable to prefix it with a custom bin directory (eg: env/bin/). see for more infos here: https://pypi.org/project/virtualenv/ and besides this cf: the documentation: https://virtualenv.pypa.io/en/latest/

cf: the documentation: https://virtualenv.pypa.io/en/latest/


here we want to shed a light on some of the most interesting Conda commands:

Well - if you ever installed Anaconda-distribution - you have some options:

- you can take the GUI installer,
- you can use the command-line-interface

Let’s look at common conda commands to create and manage conda environments.
Everything is the same whether you installed Anaconda or Miniconda.

imagine you want to create a conda environments:

Code: Select all
conda create -n my_env pandas [jupyterlab]


Create a new conda environment named myenv with the latest version of Python available on the main conda channel. and yes: if you whish to do it on Jupyterlab then you just have to add the following snippet) [ Install pandas and jupyterlab packages to the environment - just that easy]

you can do either:

Code: Select all
-n is short for --name


what it does: well in this case conda just asks you here for a concrete confirmation - in other words it asks for the confirmation with any of the above mentioned package changes that are in question. What do you have to do here: well you just have to do one thing: just hit an press y when youre asked whether you want to proceed this process.

can create a new conda environment, with program biopython with this:

Code: Select all
conda create --name munich-townhall


lets go ahead: What if you just do not want to install any program at all? in this case you can specify one or more default packages for the installation while you are just creating the environment. This is a great option doing so: in other words this allows you to call conda create without directly and explicitly providing any package name at all:


to to a setting of the provided packages, you just need to call conda config like so:

Code: Select all
    conda config --add create_me_the_default_packages_here: PACKAGE_NAME


and besides this you also can set (and choose) a package name of just "python" to get a base, empty install.


Code: Select all
conda create --name myenv python


# or just run this if you want to use some python version especially.

Code: Select all
conda create --name myenv python=3.7



here some more conda - commands that are used quite very very often:

conda info --envs : # this lists all environments
source activate <env name>: # this command activates an environment you want to use
conda env remove -n <env name> : # with this command you can delete an environment
conda env export > environment.yml:# export conda environment requirements list to a certain file
source deactivate: # and this command just deactivates an environment - try it out!
conda list : # with this command you just are able to list all packages installed on your system.
conda create --name <env name> python=3.9 : # with this you can create new environment, and yes: you of course can specify version of python;



see some great ressources for the usage of Conda: just have a closer look at the following pages:

https://gist.github.com/supriya-premkum ... cc79eef03b

https://github.com/conda/conda-build

https://gist.github.com/ctufts/fcd8bfaf ... 3bd4b52844

https://uoa-eresearch.github.io/eresear ... /20/conda/
Create virtual environments for python with conda :: How to set up a virtual environments using conda for the Anaconda Python distribution
Interessen: Bikes & steel frames: Linux & SBC https://www.allaboutcircuits.com :: die neuen Knowledge-Base: AFFiNE: There can be more than Notion and Miro. auf affine.pro :: WordPress Entwicklung - sic: make.wordpress.org/core/
User avatar
unleash_it
 
Posts: 784
Joined: 10. December 2011 18:32
Operating System: linux opensuse 12.1

Return to Allerlei

Who is online

Users browsing this forum: No registered users and 64 guests