How to Install Tkinter With Conda

Salman Mehmood Feb 02, 2024
  1. Conda Installation and Virtual Environment in Python
  2. Install Tkinter With Conda in Python
How to Install Tkinter With Conda

If you did your first steps in Python, you probably used packages because Python is a language you can use for anything, so we need these packages to develop different applications in Python according to our needs.

The problem might be that you don’t have one project, but multiple projects for multiple purposes, and all these packages are installed globally on your machine.

This can cause some problems or at least inconveniences, for that we can use the so-called virtual environments in Python.

This tutorial demonstrates why we use conda, how to install Tkinter with conda, and how we can specifically use the virtual environment in connection with conda.

Conda Installation and Virtual Environment in Python

Python is a versatile language, and you can use it for basically any application such as GUI application, web development, data analysis, artificial intelligence or machine learning. However, each of these purposes requires specific packages.

Example:

  1. For the GUI application, we might use Tkinter.
  2. For web development, we might use Flask.
  3. For data analysis, we might use Matplotlib.
  4. For artificial intelligence, we can use something like PyTorch.

These packages are not related because they have different purposes. Why would we need Flask if we want to create a GUI application?

Supposed that you also might use different versions of Python itself; for example, you might use Python 2 for other Tkinter projects and Python 3 for a different project, so you have these different versions, and these versions might fall into trouble if you are working with the same environment.

In general, the issue is that you only have one computer in the end, so the best thing would be to use individual computers for your Python installation with all the required packages. Now that’s, of course, not the solution.

The solution is that we have an unlimited amount of individual environments on our single computer; by using the so-called virtual environments, we can create separate environments for each purpose of the Python application.

If you want to manage different environments on your computer, you could install the virtualenv library; this is a tool you can download and install. This tool allows you to manage virtual environments in Python.

There is also an alternative, and it’s to use anaconda or miniconda; both are Python distributions. The anaconda or miniconda has the great advantage that they install conda on your system.

The conda is a package manager, and it allows you to create and manage your virtual environments on your machine.

Below are two approaches to creating a virtual environment.

  1. The virtualenv tool will work correctly, but the second approach is much easier.
  2. The anaconda or miniconda - use anaconda because it comes with many packages and a beginner-friendly graphical interface. But the issue is with the anaconda that comes with many packages, and if you want to look at the required packages, you can start from scratch.

The miniconda is a minimal installer for conda. It will install conda and Python and then some basic packages.

It will still allow us to install any additional packages on our machine.

Click here to install conda in your machine.

Note
Miniconda is smaller; it might be difficult to get started because you don’t have this graphical user interface. You will have to navigate through the terminal or the command prompt.

Install Tkinter With Conda in Python

The miniconda doesn’t have a graphical user interface, so we must use the terminal. So we just fired up our terminal, and if the installation worked correctly, we could now type the following command.

conda list

This command shows us all the default packages. However, if the tkinter package does not come with conda, we can install it manually, type or copy and run one of the following commands.

conda install -c conda-forge tk
conda install -c conda-forge/label/gcc7 tk
conda install -c conda-forge/label/broken tk
conda install -c conda-forge/label/cf201901 tk
conda install -c conda-forge/label/cf202003 tk
Salman Mehmood avatar Salman Mehmood avatar

Hello! I am Salman Bin Mehmood(Baum), a software developer and I help organizations, address complex problems. My expertise lies within back-end, data science and machine learning. I am a lifelong learner, currently working on metaverse, and enrolled in a course building an AI application with python. I love solving problems and developing bug-free software for people. I write content related to python and hot Technologies.

LinkedIn