
Basic of VS Code, Anaconda and Python in Ubuntu 18.04
Installing Anaconda and Conda in Ubuntu 18.04
- Download the latest version of Anaconda regarding your preferred Python version from: https://www.anaconda.com/download/#linux
- Type in terminal:
$ bash ~/Downloads/Anaconda3-5.3.0-Linux-x86_64.sh #for python3.*$ bash ~/Downloads/Anaconda2-5.3.0-Linux-x86_64.sh #for python2.*
- Be aware of the latest version of Anaconda (e.g. here is 5.3.0)
- More information can be found at the official website.
- Follow the instructions and finalise the installation through the terminal (y/n).
- In the end, it asks about the installation of VS Code. You may say 'yes' as you wish.
Installing VS Code for Python
- Install VS Code through Ubuntu Software Center or from the official website.
- If you download from official website, you may insert in terminal:
$ sudo dpkg -i ~/path/to/code_1.30.2-1546901646_amd64.deb - More information at https://code.visualstudio.com/docs/setup/linux
- Set the active environment:
Ctrl+Shift+P> type:Python: S> find from the list: Python: Select Interpreter > then select the proper interpreter. Ex. Anaconda Python 3.x
- More information at https://code.visualstudio.com/docs/python/environments
- Install basic extension of Python to ease your coding (e.g. beautiful theme, pylint, Python for VS Code).
Create a Virtual environment for your python
The virtual env would help you to install the required modules on a specific version of Python (e.g. 2.x or 3.x).
You can simply create a virtual environment by 'conda'. First make sure your conda path is correctly defined by:
$ export PATH=~/anaconda2/bin:$PATH #for anaconda 2
or
$ export PATH=~/anaconda3/bin:$PATH #for anaconda 3
Then create your env by:
$ conda create -n yourenvname python=x.x anaconda
Finally, enter your environment by typing:
$ source activate yourenvname
You can check the version in 'yourenvname' of your Python by:
$ python --version
To remove the environment:
conda remove --name yourenvname --all