-
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 0.12.3 uses Python 2.7.10 despite specifying 3.7.0 #536
Comments
Could you provide a complete |
This seems to do it:
As seen previously:
|
The same happens for me. I have installed Execution:
|
Same issue. Using macOs mojave as well. I have python 3.7 installed and it uses py2.7, no matter what I set in the pyproject.toml. Note that on a mac, even after install python 3 with homebrew,
and only
points to the python 3.7 installed by homebrew.
As you can see, 2.7 was used. (poetry-demo-py2.7) And
|
You should switch to a Python version that is supported by what you specified in your For more information about this see my comment #439 (comment). Also the documentation explains it https://poetry.eustace.io/docs/basic-usage/#poetry-and-virtualenvs Note that in a near future if you have a mismatched Python version it will raise an error to avoid this confusion. As it is, this is not really a bug only a poor user experience. I think the next bugfix release will only display a warning for now and the next major version will raise an error. |
But I did specify the Python version in my pyproject.toml (i.e. “3.7.0”) yet Poetry still doesn’t use it. |
@maxcountryman That's what I said. Your |
How do you mean? I’ve used pyenv, as I previously stated, to set my Python version. Why isn’t Poetry respecting that? To me, that seems like a bug. |
@maxcountryman Can you execute |
And also: how did you installed Poetry? |
I’ll have to take a look on Monday when I’m back at work. I installed via curl. |
Truncated result of
After running
|
That's what I suspected. You have an issue in your system since even though you execute After doing |
Hi, just chiming in to say that I also had this issue, also on macOS 10.14 Mojave. In my case, Poetry was refusing to recognise that I was using Python 3, and as such refusing to install Django 2.1. It was resolved by using This was confusing—I came here to file an issue, before finding this one and investigating further—because I had used Also, because people might come across this issue when the actual problem is that they haven't set Pyenv up properly, if after setting
I hope that helps someone, and apologies for the long post. |
That's odd. I have the exact same setup and I don't need to use I am not sure what's happening here. |
I'll try to replicate the problem on my machine in the morning. I did a lot of futzing around to get things to work and I don't want to send you off on a wild goose chase just because I forgot I did something. |
I reinstalled Poetry and Pyenv, and did not get a repeat of the |
I tried reinstalling everything, but no dice. I even tried this on a separate laptop and ran into the same issues. |
@maxcountryman Did you see my comment #536 (comment)? What's the output of |
Ah it seems to still be pointing to 2.7.x--not sure why that would be since it's a fresh install of pyenv and I've followed the rest of their setup to the T. |
I'll raise an issue with pyenv since it seems something isn't right there. Thanks! |
I realize this is a closed issue and I'm not suggesting repoening it, as there isn't a bug (the program works as designed). However, the behavior is still not ideal, and I found this page because I was running into the same issues still today months later. Not being able to specify a Python version is a huge pain on some systems. In some cases you can't just switch what the active version is. So I suggest that being able to specify a Python version be a new feature if it isn't on the roadmap. That behavior already exists with virtualenv with the Since I found this while doing random web searches for the problem I also wanted to point out a quick hack I used that effectively solved this problem for me in the hopes that it helps out others. Simply add an alias to your
Voila, the |
For what it's worth, this should be considered a bug. The official recommendation is to leave the primary Some distributions have chosen to break this packaging recommendation and in general it works OK as long as you're using software from their repos, where they've replaced all the shebangs accordingly, but on many systems, including macOS, it can and will break things to link While there's been some discussion around whether the recommendation should be maintained long-term, given that the official recommendation is for |
I also had the same issue. I have an alias for python=python3.6, so it was much harder to debug this (because |
Took a quick look at the code on this -- there are several places that directly invoke @sdispater, any general guidance here? It would also be useful if there was a high-level overview of the code's architecture somewhere. |
@trickeydan : Please scroll some post up and read @sdispater explanation about it. I would even go one step further: From January 2020 on python2 is dead. Why should poetry should take care about it anymore? |
But it does work on most distros; it just requires you to have an appropriately configured combination of python, poetry, and environment. This will always be a requirement. To me, it feels more like a configuration issue / user experience issue than a bug; sdispater (and several others) called it out as such above (as noted by @finswimmer above as well). The main justification in this thread that I see for considering it a "bug" is the reference to PEP 394, but this has been updated and no longer makes the recommendation that was initially referenced, as noted by @maggyero. In particular, PEP 394 explicitly states that python distributors may set the behavior of the Ultimately, it seems like a choice of what you want to break, not whether you want to break something. And again, given that workarounds abound for any combination of system-environment requirements, this doesn't really feel like a bug to me so much as a user experience issue. Given the breadth of (unrelated) topics discussed above (e.g., issues with |
Considering this is a tool which produces as a primary artifact a user experience over lower-level aspects of Python packaging, it boggles my mind that a user experience issue not be considered a bug. So it goes I suppose. |
@maxcountryman I agree that user experience should be a priority for a tool like poetry, but just because an issue is high priority, it doesn't make it a "bug" per se. With regard to this issue, (as noted above) poetry is behaving as intended, works properly without modification in many environments, and requires only minor modifications to system environment in others. Moreover, there is explicit justification for the current design. Contrast this with issues where poetry is behaving in an unintended way without simple workarounds, which (in my opinion) do deserve the label "bug". A few examples:
These issues may or may not deserve to be considered higher priority than a user experience issue, but are much more clearly bugs. I recognize this is just semantics, but given the core development team's stated goal of prioritizing "bug fixes" (especially prior to a non-beta 1.0 release), I think it's worth the distinction. Apologies for derailing this issue to some degree; given this issue is closed though I think further discussion of this problem probably merits the creation of a new issue. |
I've been following this issue for several months. I know what the project maintainers think.
It's deprecated. Not dead. It will live on for a long time in RHEL.
I'm saddened to hear that poetry is intended to not work with most systems. Would you consider trying to use poetry in say, Ubuntu 18.04, a common environment which is broken under python3? User experience should be valued in any tooling. Ultimately that is the purpose of tooling. The proper solution here is to call I would consider opening an issue, but the maintainers here have consistently shown ignorance to suggestions that they may not be right! Having read a lot of the community threads here, I also find some maintainers to be somewhat unfriendly to new contributors, which doesn't help. I understand that there are other bugs, but if this is not considered a bug then pyenv should be listed as an explicit requirement for usage. I don't think discussion of the semantics of "bug" is particularly useful. |
As I said above:
I am literally using poetry with vanilla Ubuntu 18.04 and python3 (3.7) right now. The only thing I had to do was make sure In my experience using linux as a development platform, (I found getting poetry to work with python 3.7 substantially easier than getting python 3.7 with pip installed on Ubuntu 18.04 in the first place.)
I'm not sure I understand. Is your point that rather than using a shebang line to determine the python to use to call poetry, poetry should bootstrap itself by first inspecting the More generally, do you take issue with this comment? (To be clear, I could imagine agreeing with the substance of the comment, but still wanting a better user experience; I'm just looking for clarification.)
If the shebang line no longer points to the environment Don't get me wrong -- I'm really not just trying to be contrarian, and would advocate for a change that was strictly backward compatible (at least as long as it didn't add any substantial amount of complexity). Sorry if I'm being dumb and a fully backwards compatible solution exists in the previous comments if I read between the lines a little harder; I just don't see how it would work though. |
No, the shebang line specifies the version of python that poetry runs under. This should be considered separate to the version of python in the project that we are managing. The calls to pip, and files in the project should be run under
I think that's an entirely reasonable decision. However the data for the runtime to use for the project is already in pyproject.toml
I think this comes back to system level python vs venv python. They can be different. From a brief read of the relevant parts of the codebase, we should be able to make this change without breaking anything.
I hope I've explained it a bit better now. TL;DR; Poetry can run under the system level python (or in a separate venv) to the python that the project is using. When making calls to pip and python for the project we can explicitly call the version that we need. |
@trickeydan Would this work / require special handling if you had disabled the use of an environment in your global poetry config? (Via |
Sorry, I thought about this more carefully. Is your suggestion to use this section of the pyproject.toml to determine which python command to use? [tool.poetry.dependencies]
python = "^3.7" I see two potential problems:
In general, using That said, I feel like this is actually just a special case of a more general problem -- having multiple python environments on your system. While python2 vs python3 is probably the most common issue along these lines, the same issue exists with python3.6, python3.7, etc., and it feels like the python2 vs python3 issue will only become less of a problem over time. I think the current approach of just forcing the But a PR that handled everything correctly and was relatively limited in scope would convince me this wasn't a problem. (Though obviously I'm not the person you need to convince 😅.) |
I think this hits the nail on the head. This concern is well-known, as there have been several issues posted about it over the last year or so. I've chosen to create a new project with a different philosophy instead of PRing this one due this design choice. Poetry's deliberately limited in scope, and makes assumptions about the user's environment. This has several advantages, but means it requires additional tools like Some issues that may come up:
I think these are more likely to be a concern for new users, or users who use different computers/OSes concurrently. I would have attempted to fix this with PRs, but since this appears to be a deliberate decision vice a bug looking for a fix, reinvented some wheels in a new project, with an as-easy-and-simple-as-possible philosophy. I believe there's a |
Thanks to everyone involved for the discussion and overall feedback. I understand that this is still a usability issue that needs to be improved. A first step towards that was the introduction of the That being said, we still need to improve the initial bootstrapping of a Poetry-managed project by trying as much as possible to find a Python version compatible with the So, to make sure everyone is aware: I want to fix this before the
This should alleviate most of the pain some users are currently experiencing. And the Note that this is the current idea, but that may change while actually implementing it. |
@sdispater Glad to see that you will make Poetry PEP 394 compliant (that is to say trying
I think you forgot to mention that |
This is now implemented (see #1477) and available in the latest beta release. |
Try this, it worked for me. User P4nd4b0b3r1n0 pointed this in https://stackoverflow.com/questions/59810276/poetry-doesnt-use-the-correct-version-of-python |
Whatever it was, seems like the fix failed for
after
poetry fails with After a
poetry finds the correct version. |
After upgrading macOS homebrew to python 3.8 today, poetry started displaying the bad/weird behavior mentioned in these reports. Poetry itself was installed with pip3 as a python 3.8 site-package and executes running the python3.8 interpreter, but seems to select only the python2.7 system interpreter to use for checking dependencies. This solved it:
Seems like poetry doesn't know about about the python3 command on macOS/homebrew unless told about it. |
Jesus Christ. How long can this issue be alive? It is 2021 already. |
@ajslater You probably should have upgraded python version in pyproject.toml for it to work. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
-vvv
option).Issue
No matter what I do, Poetry uses Python 2.7.10.
For instance, I've downloaded and specified Python 3.7.0 with
pyenv
:My
pyproject.toml
specifies:Yet
poetry update
yields:I'm completely mystified.
Infuriatingly, if I instead specify
python = "3.2"
Poetry will gladly use Python 3.2...The text was updated successfully, but these errors were encountered: