-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Poetry tries using Python2 (usr/local/bin/python) instead of the provided distribution during install #6940
Comments
So, the problem as i see it is that when poetry creates it's venv, the python executable within that venv is reporting the wrong This is with poetry 1.1.15 (we can't use 1.2.x for reasons) 3.11
3.10
|
note that using virtualenv or venv don't seem to be problematic and the hashes of the python executables within all of the virtual environment directories all match up, which seems to imply it's some configuration/environment level issue. |
Interesting, I ran something close to your command and got this:
Python 3.11:
|
@Taarek my issue may be different, but i was hoping it was the same/similar. The fact that you get I don't want to snipe your issue and make it my own so i can spin up my own. Mine revolved around trying to make a venv for a project. Running
In my case, it's almost like it's dropping the |
Ok... after making that last comment I actually found the following:
So the oddly the behavior varies based on venv as using
So there may be a fundamental issue with Python 3.11 here
though it is still suspect that the poetry venv is reporting a different version than standard venv |
So, this may really be an issue with virtualenv + python3.11 and not necessarily poetry... but it's complex This problem is likely related to: Variable 1:as part of PR 29041 for line in pyvenvcfg:
key, had_equ, value = line.partition('=')
if had_equ and key.strip().lower() == 'home':
executable_dir = real_executable_dir = value.strip()
base_executable = joinpath(executable_dir, basename(executable))
break The base executable is calculated based on the value of the Variable 2:When poetry runs commands, it does so as Variable 3:Poetry uses the system
Note that it's not using symlinks and is explicitly using copies. This is important. Variable 4:Poetry uses https://github.com/pypa/virtualenv/blob/20.16.6/src/virtualenv/discovery/py_info.py#L138 Result:Because Poetry executes Using python3:
vs
Removing poetry from the picture and creating a venv with
Using a venv with symlinks instead of copies causes it to read through
there could be an argument made, i suppose, that virtualenv should maybe validate the system executable exists prior to setting it as "the answer" Like I said, part of the problem is likely that poetry is always running "python" vs "python3" but the series of hoops to get here is complex. |
I'm new to poetry and this may be stating the obvious but I experienced this problem after updating to Ubuntu 22.04 LTS from 20.04. The only way I could work around this was to remove |
In your case, it was because Ubuntu 22.04 ships with a different Python version from Ubuntu 20.04, and the symlink to the interpreter was busted. Beware of #6371 on Ubuntu 22.04 (you may need a deadsnakes or pyenv Python because of this Ubuntu bug). |
I'm hoping this is resolved with virtualenv 20.16.7 which was just cut and should be pulled into new installs, including 1.1.15. Upstream python also accepted a fix into mainline and backported it to 3.11 that will try to fallback to a versioned binary if an unversioned one is referenced but not available in the path pointed to by |
Sidenote: If Google brought you here, |
-vvv
option) and have included the output below. (https://gist.github.com/Taarek/3e0d5eada9102d5eb69d5145e5fc34f8#file-debug_logs-py)Issue
I don't have any reproducing steps, but I used to have Poetry 1.1-something, just earlier I uninstalled it to install 1.2.2.
I made sure to use
python3.11 -
after the curl command. But for whatever reason it still tries to use Python 2?Whenever I try to run
poetry update
orpoetry install
it just fails withfailed to query /usr/local/bin/python with code 2 err: 'No such file or directory'
suddenly.I tried searching for any existing issues, but searching for "No such file or directory" or "Wrong Python" or "Python 2" gives a ton of results, so apologies if this is a duplicate.
Edit: I did find this #6841 & #6371, but I tried what both the OP and the people replying suggested, and still get the same result.
Much later edit:
Doing
poetry env use python3.10
thenpoetry install
seems to work, so is this some weird Python 3.11 compatbility issue with Debian or something? (thinking about #6371) I did build Python 3.11 myself, don't remember if I did that with Python 3.10 as well.The text was updated successfully, but these errors were encountered: