question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

poetry always uses wrong python version

See original GitHub issue
  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

Issue

~/D/c/d/backend.service.ocr 🔥🔥 cat .python-version
3.8.6⏎                                                                                                                                      
~/D/c/d/backend.service.ocr 🔥🔥 python --version
Python 3.8.6
~/D/c/d/backend.service.ocr 🔥🔥 pyenv shell 3.8.6  # just to be really sure ..
~/D/c/d/backend.service.ocr 🔥🔥 poetry install
The currently activated Python version 3.9.0 is not supported by the project (3.8.6).
Trying to find and use a compatible version.
Using python3 (3.8.6)
Installing dependencies from lock file

Package operations: 82 installs, 0 updates, 0 removals

    • Installing ipython-genutils (0.2.0): Cancelled
~/D/c/d/backend.service.ocr [1] 🔥🔥 poetry run python --version
The currently activated Python version 3.9.0 is not supported by the project (3.8.6).
Trying to find and use a compatible version.
Using python3 (3.8.6)
Python 3.9.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:8
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
magnusjacommented, Nov 9, 2020

So I couldnt really believe that, and wrote a little test script:

#!/usr/local/opt/python@3.9/bin/python3
import sys
import os

sys.path.insert(0, "/usr/local/Cellar/poetry/1.1.4/libexec/lib/python3.9/site-packages")
sys.path.insert(0, "/usr/local/Cellar/poetry/1.1.4/libexec/vendor/lib/python3.9/site-packages")

if __name__ == "__main__":
    os.system("which python")
    os.system("python --version")

which gives

~/D/c/l/shopfloor (feature/adapt-box-detection|…) 🔥🔥 ./test.py
/Users/magnus/.pyenv/shims/python
Python 3.7.5

so clearly it is possible for poetry to get the correct python env.

Also imho if this is expected behavior you are following an incredibly bad & flawed UX. Basically poetry is telling me it is using python 3.8 and lying to my face instead of throwing an error. It took me quite a while to figure that out …

1reaction
magnusjacommented, Dec 8, 2020
~/D/c/l/r/h/training (develop|✚4…) 🔥🔥 pyenv shell 3.8.5
                                                                                                                                   [ 0s053 | Dec 08 05:02PM ]
~/D/c/l/r/h/training (develop|✚4…) 🔥🔥 poetry env use /home/magnus/.pyenv/shims/python
Creating virtualenv training-9MFdeoy7-py3.8 in /home/magnus/.cache/pypoetry/virtualenvs
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'PosixPath' is not defined
Using virtualenv: /usr
                                                                                                                                   [ 0s951 | Dec 08 05:02PM ]
~/D/c/l/r/h/training (develop|✚4…) 🔥🔥 poetry run python
Python 3.9.0 (default, Oct  7 2020, 23:09:01) 
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

The env also seems broken

Read more comments on GitHub >

github_iconTop Results From Across the Web

Poetry using the wrong Python version (not related to pyenv)
Poetry should implicitly create a built-in virtual environment with the Python version specified by the tool.poetry.dependencies.python property ...
Read more >
Poetry doesn't use the correct version of Python - Stack Overflow
The currently activated Python version 2.7.16 is not supported by the project (^3.8). Trying to find and use a compatible version.
Read more >
Managing environments | Documentation - Poetry
By default, Poetry will try to use the Python version used during Poetry's installation to create the virtual environment for the current project....
Read more >
Select python interpreter in poetry | by Jamie Thomson - Medium
I used poetry to discover the version of python currently being used in the project: As you can see it is using python...
Read more >
Poetry Advance - Python Biella Group
If you just wish to define the most recent version, use “*.” You may also define the Python version necessary to run the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found