How to add a Conda environment to PyCharm and DataSpell

Adding the Conda environment to PyCharm or DataSpell will help you use the package you added to the Conda environment, and you can install additional packages to the Conda environment using PyCharm and DataSpell Terminal. You don’t need to waste space creating new environments for small projects.

Add Conda environment to PyCharm

To add Conda environment to PyCharm or DataSpell, you need to follow these steps:

Step 1: Open the application’s Settings using the menu above.

Go to PyCharm's settings
Go to PyCharm’s settings

Step 2: Go to the Python Interpreter section, click the Add Interpreter button and choose Add Local Interpreter.

Go to add environment in PyCharm
Go to add environment in PyCharm

Step 3: Go to the Conda Environment section and choose the created Conda environment. If you don’t see your Conda environment, click the Load Environments button to update the Conda environment list.

Add Conda environment to PyCharm and DataSpell
Add Conda environment to PyCharm and DataSpell

In addition, you can also create a Python virtual environment with Conda right in the PyCharm and DataSpell applications.

Create a new Conda environment in PyCharm and DataSpell
Create a new Conda environment in PyCharm and DataSpell

Step 4: Review the Conda environment added to PyCharm or DataSpell and click the OK button to complete.

Review the Conda environment added to PyCharm and DataSpell
Review the Conda environment added to PyCharm and DataSpell

Managing virtual environments in Pycharm

To see the list of Conda environments you have added to PyCharm, click Show All in the Python Interpreter section.

Manage the list of environments added to PyCharm or DataSpell
Manage the list of environments added to PyCharm or DataSpell

You can delete or edit Conda environments in the environment list window in PyCharm or DataSpell.

Conda environments can be edited, deleted, or added in this window
Conda environments can be edited, deleted, or added in this window

Choose the Conda environment when creating a new project

When creating a new project in PyCharm or DataSpell, you should choose the Base conda environment if it is a data science project. Because Anaconda’s Base conda environment already includes more than 500 premium packages for data science.

Choose the Base conda environment for your data science PyCharm project or general work
Choose the Base conda environment for your data science PyCharm project or general work

You can add another Conda environment to PyCharm or DataSpell by clicking Custom environment.

Choose a different Conda environment for the new PyCharm project
Choose a different Conda environment for the new PyCharm project

Change the Conda virtual environment for a project

If you are working on a project and want to change its environment, click the current environment name in the lower right corner. You’ll see the Conda environments you added to PyCharm or DataSpell.

Click on the current environment name to change to another Conda environment
Click on the current environment name to change to another Conda environment

Conclusion

We should add the Base conda environment to DataSpell and PyCharm for daily work. For special projects that need to share Conda environment information with other members, we should add a new Conda environment.

Hieu Tran Ngoc Minh

Hieu (born in 1996) holds a Bachelor's degree in Business Administration from Saigon Technology University. Currently a Data Analyst at Ninja Van, Hieu has extensive experience in Data Analysis and Digital Marketing. This blog is where Hieu shares practical experiences from work and life.

Leave a Comment

Feel free to leave your comment, and we will review and respond as soon as possible. Please use a real email to ensure your comment is approved and to receive notifications when we reply. You can also add an avatar to your email.