1 Introduction
1 Introduction
2
What is Python
3
Conda
4
The Anaconda Distribution
5
Miniconda
6
Python IDE
7
Pip: Properly Installing Python
8
What is pip
• You can also give pip a version specifier for a package using one or more of
==, >=, >, <, <=:
pip install 'pandas<2.0'
• This will install the latest version of pandas lower than 2.0 (e.g. 1.9)
• You can also combine version specifiers with a comma:
pip install 'pandas>2.0,<2.0.3'
• You can use the list command to see the packages installed in your
environment: pip list
10
Upgrading a package
11
Uninstalling a package
12
Python virtual environments
13
Python virtual environments
• Python, like most other modern programming languages, has its own
unique way of downloading and storing packages (3rd party libraries)
• Every Python project on your system will use these same directories to
store and retrieve these packages
• At first glance, this may not seem like a big deal, and it isn't really, for
system packages (packages that are part of the standard Python library), but
it does matter for site packages
14
A worst-case scenario
• Consider the following scenario where you have two projects: ProjectA and
ProjectB, both of which have a dependency on the same library, ProjectC
• The problem becomes apparent when we start requiring different versions
of ProjectC
• Maybe ProjectA needs v1.0.0, while ProjectB requires the newer v2.0.0
• This is a real problem for Python since it can’t differentiate between
versions in the site-packages directory
• So both versions would reside in the same directory with the same name
15
What Is a Virtual Environment?
16
Creating a virtual environment
17
The PyCharm IDE
What is PyCharm
• Once you have run PyCharm you need to select Create a new Project
• On the next screen select Pure Python
• Select the name and location of your project
• Then we need to setup the environment used by the project. We can:
• Create a new environment
• Use an existing Python interpreter (with the base environment)
• Use an existing environment
20
Select an existing environment
• Environments created with conda live by default in the envs folder of your
Conda directory, whose path will look something like:
• % /Users/<username>/miniconda3/envs
• C:\Users\<username>\AppData\Local\Continuum\anaconda3\envs
• We can use the wizard to navigate to the specific environment and select
the seminarenv environment we just created
• Once we are ready click on Create and the new project will be created
• The above can all be found in the excellent online guide at
https://www.jetbrains.com/help/pycharm/quick-start-guide.html
21
Install, uninstall, and upgrade packages
22
Overview of the user interface
23
Let's start coding
24