Correct Steps to setup basic environment for Python
Set up python development environment with conda
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
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.
- Click "Next" if you do not have a preferred destination folder
- 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 )
- Wait until it finishes. Click "Next"
- Unchecked all 2 boxes as we will not use Anaconda. Clicked "Finished"
- 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)"
- A command prompt will be opened. Type
conda -V
and it will show the conda version if you installed Miniconda correctly
- 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)
- Go back to the command prompt we have opened.
Please typeconda create -n <your environment name> python=3.8
and click "Enter". (e.g.conda create -n myFirstApp python=3.8
)
- Type "y" and press "Enter"
- After finished loading, you need to type
conda activate myFirstApp
in order to activate the environment we have created
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 typeprint( 'helloWorld' )
to print out the text "helloWorld"
- 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.