How to Configure Python Programming Environment

How to Configure Python Programming Environment

Table of contents

No heading

No headings in the article.

Introduction

The programming environment is the environment that allows users to execute their code on their laptops/personal computers. If you want to run a python program or if you are going to make an application using python programming language then the first thing you will need is to configure your programming environment which enables you to execute your program. In this blog, I will guide you on configuring your python programming environment. The distribution/platform which we are going to use is Minconda which helps us to configure our programming environment. If you want to study more about Miniconda here is the link

Installing Miniconda

First of all, we need to install Miniconda on our laptops/pc. Visit this link and install the miniconda according to your operating system. There are different versions. Download the miniconda according to your operating system (windows, macOS, or Linux).

Screenshot 2022-11-27 at 4.24.57 PM.png

After downloading the setup, install the miniconda by default setting. The miniconda comes with preinstalled python 3.9. So you don't need to install python separately. In the future, if you want to install another python version you can do this by running one simple command which we will see further.

Configuring the Environment

After installing miniconda open the anaconda prompt. Anaconda prompt is the same as the command prompt in windows or terminal in macOS and Linux operating systems. As I am using macOS so I have to open the terminal, you have to open the anaconda prompt if you are using windows. The command prompt will look like this as

Screenshot 2022-11-27 at 4.40.23 PM.png

To check that miniconda is installed in our operating system run this command

conda info

It will show some output. It contains information regarding your environment.


     active environment : base
    active env location : /usr/local/Caskroom/miniconda/base
            shell level : 1
       user config file : /Users/mudassar/.condarc
 populated config files : 
          conda version : 4.13.0
    conda-build version : not installed
         python version : 3.9.12.final.0
       virtual packages : __osx=10.16=0
                          __unix=0=0

The miniconda comes with a default environment which is the base environment. In this base environment, there are some prebuild packages or dependencies that are already installed like python 3.9.7 comes with this base environment.

Screenshot 2022-11-27 at 4.51.12 PM.png

To check the packages installed in the environment run this command

conda list

To create a new environment / virtual environment run the below command. The new environment will be empty you have to install packages in it according to your requirement. And you have to install python in it to run your python program. Following is the command to create the new virtual environment and install a specific python version according to your requirement.

conda create --name myEnv python=3.10

In the above command, I am creating the new environment name myEnv and installing python 3.10 in it. After running this command you have to activate this new environment using this command

conda activate myEnv

Now enter python after activating the environment. Finally, you can write your first program "Hello World" using python in this new environment

(myEnv) mudassar@apples-MacBook-Pro ~ % python
Python 3.9.12 (main, Apr  5 2022, 01:53:17) 
[Clang 12.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print("hello world!")
hello world!
>>>

To exit from the python interpreter run this command

exit()

You can access all conda commands from this conda cheat sheet

Conclusion

Thanks for staying with me. In this short time, we learned how to configure the python programming environment and run your Hello World program using python. Next, I will show you how to install jupyter notebook in your environment and how to use jupyter notebook for further python programming. If I miss any step or if you have any queries feel free to ask in the comment section. I will see you in my next article until then Happy Coding..