Correct Steps to setup basic environment for Python

Set up python development environment with conda

·

3 min read

Correct Steps to setup basic environment for Python

Summary

We provide a step by step tutorial to guide you using miniconda to set up a Python development environment, which can cope with the following challenges you may face when:

  • Struggle to learn python but do not know how to start
  • Manage Python packages (or in another word, programs written by others) you use
    (Especially, you have installed tons of packages)
  • Develop several programs but using different versions of python and different packages

Content

Step 1, Download Miniconda

  • Please download Miniconda on the site docs.conda.io/en/latest/miniconda.html.
  • Select the installer according to the OS. In my case, I will select Python 3.8 for Windows.
    Tips: Better NOT to install the latest version (i.e. 3.9 at this moment) as the latest version may be unstable or some Python packages are still NOT compatible with this version

image.png

Step 2, Install Miniconda

  • After you downloaded it, you will have an execution file. Open it and click "Next".
  • After agreeing to the license agreement, you will need to select an installation type. Select "Just Me" and next.
    Tips: "Just Me" is recommended not only because it does not require administrative permission, but also can reduce the risk that Miniconda or the program you developed may cause the software of your PC to malfunction.

image.png

  • Click "Next" if you do not have a preferred destination folder

image.png

  • Click "Install".
    ( You may check "Register Miniconda3 as my default Python 3.8" if you want your IDE (i.e. a tool, which help you to develop faster) to detect it automatically )

image.png

  • Wait until it finishes. Click "Next"

image.png

  • Unchecked all 2 boxes as we will not use Anaconda. Clicked "Finished"

image.png

  • We have finished installed Miniconda.

Last Step, Create a conda environment

This is to create an independent environment for development.
(An environment can be understood as a room, which you bring tools (i.e. package) into that room to build something (in our case, program))

  • Press Windows button and search anaconda. Select "Anaconda Prompt (Anaconda3)"

image.png

  • A command prompt will be opened. Type conda -V and it will show the conda version if you installed Miniconda correctly

image.png

  • We will create an environment for development.
    You can check the stable version of python from python.org/downloads.
    We select one version (3.8) less than the latest version (3.9)

image.png

  • Go back to the command prompt we have opened.
    Please type conda create -n <your environment name> python=3.8 and click "Enter". (e.g. conda create -n myFirstApp python=3.8)

image.png

  • Type "y" and press "Enter"

image.png

  • After finished loading, you need to typeconda activate myFirstApp in order to activate the environment we have created

image.png

After you executed the command, you can see your environment name appeared at the beginning of the command. Great! You have created your environment

  • In order to test your environment, you can first type python to open Python Shell. Then, you can type print( 'helloWorld' ) to print out the text "helloWorld"

image.png

  • We have created a new conda environment, called "myFirstApp"

Remark

  • Each conda environment is isolated from each others. It means that the package you have installed in A environment (e.g. myFirstApp in our case) will NOT affect the environment B (e.g. base)
  • When you are installing Miniconda, you may notice "Anaconda" has also appeared. Anaconda contains Miniconda, and also a bunch of tools used for data science. As we used python for software development, we do not need to install "Anaconda".
  • If later, you would like to use miniconda for data science, you can install those tools manually. No need to worry.

Did you find this article valuable?

Support Ivan Yu by becoming a sponsor. Any amount is appreciated!