Python Setup

Introduction
Well, hello there! This is about setting up my system to support Python development, creating Python projects, and some important gotchas.
Software
| Name | Type | How To Get | Purpose |
|---|---|---|---|
| poetry | Package Management | Website | The fedora version is old and missing some functionalities. Get the latest from their website. |
| pyenv | Version Management | Setup | Manage Python environments |
| PyCharm | IDE | JetBrains Toolbox | My IDE of choice |
Installing other Python versions
The preferred way to get additional Python versions is using pyenv. Now, running pyenv install 3.X.X may fail because of missing libraries. See this to get all dependencies. Or run the following command.
Poetry Setup
See this page on getting pyenv and poetry to work together. You'll need to set an experimental flag (and require a newer version of poetry).
Create a Python project
This assumes that you have a pre-existing empty project.
The pyenv command gets poetry to use that copy of python and not the default system version. At this point you can open the project in PyCharm.
- You may need to add the Python Interpreter that was created by poetry. It's located at
~/.cache/pypoetry/virtualenvs/<interpreter-name>/bin/python
PyCharm and Poetry
Some issues with PyCharm and Poetry playing nicely.
- PyCharm seems to have a problem with poetry managing dependencies. It seems unable to update the virtual environment, so I'm managing packages directly using poetry.
- To get PyTest to work, I needed to update the PyCharm settings in
Settings -> Tools -> Python Integrated Tools -> Default Test Runnerto use PyTest. It'll give a warning about no PyTest runner, but after restarting (and waiting) it'll find the PyTest tests and allow running them.
Libraries
These are some common libraries I've use a lot for development.
| Name | Type | How To Get | Purpose |
|---|---|---|---|
| loguru | Logging | pip | Logging Framework |
| pytest | Test | pip | Testing Framework |