How to install Python 3 and virtual environments with Miniconda in Ubuntu 18.04

Chi Thuc Nguyen
2 min readFeb 11, 2019

Download and install Miniconda

Download latest version of Miniconda here: https://docs.conda.io/en/latest/miniconda.html

Then run the installation script:

bash Miniconda3-latest-Linux-x86_64.sh

Restart your terminal to reload the environment variables, then check the installed conda version:

conda --version

Update conda to latest version

conda update conda

Managing virtual environments

Create new virtual environments

conda create --name {env_name} python={python_version}

For example:

conda create --name p37 python=3.7

Delete a virtual environment:

conda remove --name {env_name} --all

Activate and deactivate virtual environment

List all virtual environments:

conda info -e

Activate a virtual environment:

conda activate {env_name}

Deactivate current virtual environment

conda deactivate

List all installed packages in current virtual environment:

conda list

Install Python packages

conda install {package_name}

Example: conda install flask

You can also install multiple packages at the same time by specifying list of packages separated by spaces.

Uninstall Python packages

conda uninstall {package_name}

or:

conda remove {package_name}

Update Python packages

conda update {package_name}

Search for a package

conda search flask*

Using conda virtual environment in PyCharm

In PyCharm, go to File > Settings… > Project:… > Project Interpreter.

Click on the settings icon on the right of Project Interpreter drop down, select Add…. Chose Conda Environment, and select your virtual environment from Existing environment:

And you now have your Python development environment ready.

Congratulations!

--

--