Conda is a part of the Anaconda Distribution. It is installed by most people through the installation of Anaconda or miniconda, a minimal installer for conda that includes conda and its dependencies (Python, the packages they depend on and a small number of other useful packages, including pip, zlib and a few others). Conda can also be installed independently of Anaconda/miniconda, in a system that has Python and pip installed using:
pip install conda
However, the above method will not give Conda as a standalone application, as the currently supported install methods include the Anaconda installer and the miniconda installer. To install miniconda download the appropriate installer from here, or for a x64 system and Python 3 at the cli:
$ wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh $ bash Miniconda3-latest-Linux-x86_64.sh
Installing Anaconda means you will be using a minimum of 3 Gb of your disk space while installing miniconda means you will be using around 400 Mb. Also, you will have to adapt to the work-flow required by the tools and conda-environments you will be using. Of course adapting to a certain work-flow will happen with whatever tools, environments, etc. one might use.
Installing Anaconda is quite trivial and one can start developing, researching, learning almost immediately after installation. Depending to what extend one might use Anaconda (or miniconda) for, the above setup might be ideal or even redundant.
Pyenv, pipenv, Jupyter Notebook, JupyterLab
For someone with some experience with command line and python, a similar setup can be achieved with a little more effort, allowing you to also gain valuable knowledge in the process. Based on the guide written by Henrique Bastos, we are going to:
- install pyenv - a simple Python version management
- create some directories and some global variables
- Install some Python versions
- create virtual environments with these Python versions
- Install pipenv - a tool that aims to bring the best of all packaging worlds (bundler, composer, npm, cargo, yarn, etc.) to the Python world.
- Install Jupyter Notebook and JupyterLab
- Incorporate all the above in a single script to run things faster.
The script will create two directories, one for virtual environments, and one to use as a workspace for projects:
sudo apt update # Install required sudo apt -y install unzip wget curl build-essential sudo apt -y install python-dev python3-dev # install pyenv curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash source ~/.bashrc git clone https://github.com/pyenv/pyenv-virtualenvwrapper.git $(pyenv root)/plugins/pyenv-virtualenvwrapper mkdir -p $HOME/.envs mkdir -p $HOME/workspace echo 'export WORKON_HOME=~/.envs' >> ~/.bashrc echo 'export PROJECT_HOME=~/workspace' >> ~/.bashrc source ~/.bashrc # Install python versions 3.6 and 2.7 and create virtual environments for jupyter to work globally. pyenv install 3.6.6 pyenv install 2.7.14 pyenv virtualenv 3.6.6 jupyter3 pyenv virtualenv 2.7.14 ipython2 pyenv activate jupyter3 pip install --upgrade pip pip install jupyter pip install jupyterlab python -m ipykernel install --user pip install ipywidgets jupyter nbextension enable --py widgetsnbextension --sys-prefix pyenv deactivate pyenv activate ipython2 pip install --upgrade pip pip install ipykernel python -m ipykernel install --user pyenv deactivate # Set system wide python versions pyenv global 3.6.6 2.7.14 jupyter3 ipython2 pip install --upgrade pip pip install pipenv echo 'pyenv virtualenvwrapper_lazy' >> ~/.bashrc echo '# For pipenv' >> ~/.bashrc echo 'eval "$(pipenv --completion)"' >> ~/.bashrc source ~/.bashrc ipython profile create curl -L http://hbn.link/hb-ipython-startup-script > ~/.ipython/profile_default/startup/00-venv-sitepackages.py
To run the script:
- Create a .sh file in your home (~) directory, eg. pyenvscript.sh.
- Copy the above script and paste in the file.
- Run the script in a terminal:
You should now be able to:
- Simply use virtualenvwrapper’s commands and each virtualenv will be created using the Python interpreters installed via pyenv.
- Use pipenv the official Python-recommended resource for managing package dependencies
Example usage would be:
cd ~/workspace mkdir myproject && cd myproject # create a new project with python 3.7.0. # If pyenv is installed pipenv will automatically download and install python 3.7.0 pipenv --python 3.7 pipenv run which python pipenv shell python --version pipenv install numpy pipenv install scikit-learn exit
Similarly to miniconda the above setup would provide a development environment that could be used to develop Python projects, install learning tools, like fast.ai, etc. With pyenv-virtualenv you could even manage conda environments by “conda create” as same manner as standard Anaconda/Miniconda installations. At about 400 Mb you have two Python versions installed with pip and tools (Jupyter NB, JupyterLab, pipenv). You would be required to install various dependencies according to your project, unlike Anaconda where almost everything is installed by default, but that is in the procedure of learning and developing.
So unless you are a pure data-scientist dealing only with the PyData-ecosystem and looking to build a robust python environment for development, learning or researching , maybe Anaconda and Miniconda is not the only way to go.
References for further reading: