-
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
Request for documention on how to use poetry with multiple python versions #305
Comments
This issue is very relevant. Pipenv is making a lot of fuzz at the moment, but pipenv project management is just (imho) atrocious. As a pipenv refugee myself, i found the way that poetry controls virtualenvs very frustrating and un-intuitive, and there was not a lot of info regarding it - it took me some time to stumble into poetry and virtualenvs docs page where i found an explanation. I would really love for it to be clarified. And also honestly it would be amazing if you could set a python version of virtualenv with poetry instead of some roundabout way. |
After explanation in #82 i started use pyenv but at the end i would prefere choosing python version at poetry install |
After spending some time reading other issues where its mentioned (#9 #35 #57 #77 #82), here's a summary: A lot of people get confused about what poetry does and what it doesnt do in regard to virtualenv. It actually is kind of an edge case where it always tries to create virtualenv and work inside of it, but it doesnt provide any support for different virtualenvs and such. Here are my thoughts on this. Poetry can either:
Regardles of whatever gets chosen as a solution, we should really update the documentation as it is a common point of confusion among new users (myself included). |
Can't we just make [UPDATE] Just found that you can configure poetry to create virtualenv in project dir, but the path is fixed to See https://poetry.eustace.io/docs/configuration/#settingsvirtualenvsin-project-boolean |
I was very careful to ensure that the scope of this issue was focused on documentation only when writing it to avoid a prolonged argument on how Having said that, I am not saying that if someone has a request to change behavior they should not pursue it; rather, those requests probably belong in a different issue focused on behavior changes to |
@SethMMorton agreed, adhering to |
I agree that the documentation should be clearer as to how to use Poetry to manage multiple python versions. The idea when I started Poetry that it would work like Bundler in Ruby or NPM in JS. Basically, you would use a specific tool to manage Python versions, like Basically:
This is a process similar to what exists in other languages, like those mentionned above. The use of virtualenvs is just a side effect of the Python ecosystem but, to me, it should be completely transparent and not something the end user should have to worry about or even know is there. It's unlikely that Poetry will integrate a Python versions management tool. This is not the purpose of a package/dependency manager and their are other tools that do it well, That being said, the documentation should be updated with complete step by step instructions. |
Sorry for diverging this issue from its original direction. The above comment explains the intended workflow in a clear way. I will create a draft for documentation update in a couple of hours with a pull request unless someone wants to do it. |
@festinuz That would be great! I was planning on doing the same once I finished another project, but who knows when that will be done. |
I've created a #332 pull request with some groundwork for documentation regarding this topic.
|
+10 for better explanations on differences with pipenv, and recommended workflow, for newbies! As a new |
I am cross-posting this comment from the #332 PR because it seems relevant here as well. I like pyenv (I use it at home), but there may be an issue with recommending it as the only way to manage multiple python versions because it does not support windows (pyenv/pyenv#62) and it does not look like that will happen in the future either. Is there a cross-platform or windows-specific alternative that can be demonstrated/recommended as well? |
Thanks, @SethMMorton . By the way, i kinda left my PR hanging (sorry!), since the comments on said PR raised questions i cant answer for poetry - like the one you cross-posted here. There isnt any good looking way to use poetry at the moment, to be honest. Every option feels clunky or limited in some way. |
@SethMMorton I agree that there is no alternative to pyenv on Windows at the moment which is an issue to have any Python version installed on a Windows system. However, this is beyond the scope of Poetry and you will need to manually install the needed Python versions. This is a limitation of the Python ecosystem at large. Note, however, that the new WIP installer (#378) will simplify things by requiring only one installation of Poetry. The This will not solve the problem of the absence of a good tool on Windows to manage Python versions but it should help not having to install it multiple times. |
I just want to clarify that I did not bring up My understanding is that |
No, Basically, the automatic creation and detection of the virtualenvs is what |
I guess my confusion comes from the fact that The heart of the reason I filed this issue was that it was unclear to handle this situation, and I was hoping to rectify that by improving the documentation. I hope you do not feel like I am badgering you with all these questions, I just want to help improve the tool! |
I have multiple python versions already installed in the system. I was surprised, that poetry could not pick it up automatically:
Is there a way to specify it manually? I have never used |
@sirex I think if you create a virtualenv ( |
@garyo thanks for the workaround suggestion. Still it would be nice if poetry could pick latest required version automatically without any workarounds. Of course if there is no required python version available, then it could fail. |
I'm not sure how you'd want that to work -- should |
Currently And it creates this virtualenv using a system python. So instead of blindly taking |
Actually, conda is (to my knowledge the only) cross-platform tool which can be used to install various python versions on Windows/Linux/macOS. It's mostly used within a scientific community so not many people are aware of it. With the silent mode installation and a bit of pain you can build seamless cross-platform provisioning and deployment. On a first glance using |
This EXACTLY is what is ruining my poetry adoptation at the moment. I have multiple python projects with different python versions. I have currently in the pyproject.toml
But the This is not merely a documentation issue, this is a clear violation of POLA. Either create virtualenv using correct version of python or abort (fail fast, fail hard). Now, does multiple poetry installations for each python version sound good to anyone? Not at least to me .. this needs to be handled better. |
@paranoidi with
Also, Poetry uses whichever Python version is currently active if you've installed |
I think Poetry should just use whatever environment it's in, and not creating a virtualenv. |
Given that #731 is implemented, merged, and documented, this solves the spirit of this issue. I will close the issue now. |
For me this is even worse, my system python is on 3.10 but in a current project I need to use tensorflow which only supports up to 3.9. So I have
Which causes all sorts of problems. My only way of fixing it seems to be to install pyenv and use that as poetry cannot downgrade automatically it seems, at least |
* factory: merge legacy dependencies and groups This change ensures that existence of legacy "dev-dependency" section does not break when "dev" group is added for new dependencies. * package: remove redundant filtering * fix typing for `ProjectPackage.python_versions`
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. |
Issue
In order to frame my request, let me describe how I anticipate some users come to use poetry (this at least was the case for me):
setup.py
(making them feel like a second-class citizen), and/or b) the responses to issues filed for pipenv are usually either rude or dismissive.For people like myself that came to poetry by way of pipenv, the approach to managing virtual environments taken by poetry tripped me up for quite some time because it differs significantly from pipenv.
.venv
.This is a fundamental difference in philosophy between the tools which leads to a fundamental difference in usage on this specific aspect of project/dependency management. Because I had been first exposed to the pipenv way, I (wrongly) assumed that poetry also worked this way and struggled to get poetry to use a python 3.5 virtual environment because I had installed poetry against python 3.6; this was especially confusing because I had set the python version in the
pyproject.toml
to 3.5. I did notice the Poetry and virtualenvs section, but for someone who has not yet grokked the design philosophy of poetry there is not enough information for someone used to what pipenv does to adapt to poetry's approach.REQUEST (finally)
I think the documentation for poetry would be improved if one (or both) of the following were added to documentation:
pyenv
and also using a pre-existing.venv
. This could just mean expanding the Poetry and virtualenvs section.It would also be helpful if this information were in the README itself, or at least linked to in the README.
The text was updated successfully, but these errors were encountered: