Skip to content

Commit 2844f15

Browse files
committed
Add poetry troubleshooting across python versions
1 parent 4666ea1 commit 2844f15

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

README.md

+21-5
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ Mini blog to myself about the technical steps to get a python development enviro
1111
- [List Versions you **CAN** install](#list-versions-you-can-install)
1212
- [List Versions that **ARE** installed](#list-versions-that-are-installed)
1313
- [Check and Activate a Version](#check-and-activate-a-version)
14-
- [Troubleshooting](#troubleshooting)
14+
- [PyEnv Troubleshooting](#pyenv-troubleshooting)
1515
- [Resources](#resources)
1616
- [Poetry](#poetry)
1717
- [Install / Upgrade](#install--upgrade)
1818
- [Configuration](#configuration)
19-
- [Troubleshooting](#troubleshooting-1)
19+
- [Poetry Troubleshooting](#poetry-troubleshooting)
2020
- [Invoke Common Tasks](#invoke-common-tasks)
2121
- [Install / Upgrade](#install--upgrade-1)
2222
- [Configuration](#configuration-1)
@@ -97,7 +97,7 @@ pyenv version
9797
3.10.3 (set by /Users/joshpeak/.pyenv/version)
9898
```
9999

100-
## Troubleshooting
100+
## PyEnv Troubleshooting
101101

102102
1. Always use `python3` and not `python`. This could resolve to a python2 installation.
103103
1. Use `which -a python3` to figure out ALL `python3` binaries that could resolve from `PATH` environment variables and in which order.
@@ -150,9 +150,9 @@ You definitely want to create virtual environments only in the same folder as yo
150150
poetry config virtualenvs.in-project true --local
151151
```
152152

153-
## Troubleshooting
153+
## Poetry Troubleshooting
154154

155-
99% of problems are resolved by resetting a borked virtual environment.
155+
1. 99% of problems are resolved by resetting a borked virtual environment.
156156

157157
```sh
158158
rm -rf .venv && rm poetry.lock
@@ -164,6 +164,22 @@ Then:
164164
poetry lock && poetry install
165165
```
166166

167+
2. When `deactivate`ing a poetry shell sometimes you need to `unset POETRY_ACTIVE` to clean the environment variables.
168+
169+
3. Issues with `poetry` across multiple version of Python, `poetry` is installed _**per Python version**_.
170+
171+
Use the following when in doubt:
172+
```sh
173+
python3 -m install -U poetry pip
174+
python3 -m poetry shell
175+
```
176+
1. **The problem**: When I run `poetry` on the commandline it resolves based on my `PATH`
177+
2. So `python3 --version` could show `3.9`, but `poetry` is installed in my `3.8`
178+
3. `poetry` will create a virtual environment based on the `python3` interpreter that it is being run in.
179+
4. `python3 -m poetry` uses the exact version of `poetry` that is relative to the same `python3` you are expecting because you are using _module mode_ (`-m`).
180+
5. This is part of the reason you upgrade `pip` using `python3 -m pip install -U pip` to make sure you are updating the same `pip` as your target `python3` interpreter.
181+
6. This is why I only activate `pyenv` on demand to have least magic on my `PATH` at any given time.
182+
167183
---
168184
# Invoke Common Tasks
169185

0 commit comments

Comments
 (0)