PyCharm and Virtual Environment

Ece Altıparmakoğlu
4 min readMay 26, 2021

Hi everyone, here is my first article!

What is this Pycharm?

Pycharm is an IDE (Integrated development environment) program created for python. It gathers all development tools in one place and offers a powerful and easy use. It has two different version; Professional and Community. The Professional version is paid but provides one year free use for students. Community version is completely open source and free.

So why PyCharm? What does this IDE offer us?

  • It has been developed to work in all operating systems.(Windows, Mac OS, Linux)
  • PyCharm integrates with IPython Notebook, has an interactive Python console, and supports Anaconda as well as multiple scientific packages including Matplotlib and NumPy.
  • It has features such as smart code inspections, on-the-fly error highlighting and quick-fixes. This features making PyCharm a favorite IDE by users in the python world.
  • Language and framework-specific refactorings helps perform project-wide changes.
  • It saves time by working with Git or other version control systems.
  • Provides direct access to various database systems.
  • Virtual environment and dependency management is very easy with PyCharm.

Let’s continue with Virtual Envioronment

realpython.com

A virtual environment is a tool that helps to keep dependencies required by different projects separate by creating isolated python virtual environments for them. This is one of the tool that most of the Python developers use. Let’s make it clear with an example;

Imagine a scenario where you are working on two python projects and one of them uses a Pandas 1.1 and the other one uses Pandas 1.2.

This is exactly where virtual environments come into play! Two separate virtual environments shoul be created for both projects. If a library needs to be upgraded to 3.0 in an environment with Pandas 1.1, this will not affect the environment in Pandas 1.2 which already has been installed.

It is generally good to have a new virtual environment for every Python based project works on. So the dependencies of every project are isolated from the system and each other.

How to create a virtual environment from scratch (Windows)

I will explain these steps on Anaconda. Firstly we have to install Anaconda. After installation, open the “ anaconda prompt”. After that, enter ‘creat conda -n environmentsname’ which is the command. Actually the name given to our new virtual environment is “ environmentsname”.

command to create new virtual environment

Now suppose we want to install a specific version of python. In this case the code should be as follows:

The next step is to activate the environment we have created before. Here you should use the ‘conda activate environmentsname’ command. After activitation process completes, the environment changes from ‘basic’ to the ‘environmentsname’.

Now let’s install the current version of numpy and pandas 1.2.1. Thus, we will observe multiple libraries while installing both the current version and a specific version at the same time.

We can view the details of installed libraries with the ‘conda list’ command.

Let’s try to upgrade the version of pandas. Of course, we use the ‘conda upgrade pandas’ command for this.

Now let’s see how to export a yaml type which has already been created environment.

Finally, let’s delete the environment we created. Attention! Virtual environment must be deactivated before removing.

As we can seen, after the deactivation process, the environment is transformed to ‘base’ again instead of from the ‘environmentsname’.

I hope it has been useful :)

Thank you!

--

--