Skip to content
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

[question] How to use poetry on Ubuntu? #1543

Closed
jabbalaci opened this issue Nov 5, 2019 · 19 comments
Closed

[question] How to use poetry on Ubuntu? #1543

jabbalaci opened this issue Nov 5, 2019 · 19 comments
Labels
kind/bug Something isn't working as expected

Comments

@jabbalaci
Copy link

I made a poetry-based project on Manjaro, where python3 is the default.

On another machine, which has Ubuntu 18.04, I wanted to re-create the virt. env. but I got the following error:

$ poetry install                              
/home/jabba/.poetry/lib/poetry/_vendor/py2.7/subprocess32.py:149: RuntimeWarning: The _posixsubprocess module is not being used. Child process reliability may suffer if your program uses threads.
  "program uses threads.", RuntimeWarning)
                                                                              
[RuntimeError]                                                 
The current Python version (2.7.15) is not supported by the project (^3.6)  
Please activate a compatible Python version.

Under my Ubuntu python points to Python 2.7, it's true, but Ubuntu has a python3 symlink that points to Python 3.6.

I think poetry should pick Python 3 automatically. But anyway, how can I create a Python 3 virt. env. in this case? Thanks.

@jabbalaci jabbalaci added the kind/bug Something isn't working as expected label Nov 5, 2019
@jabbalaci
Copy link
Author

I even tried this trick:

curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python3

Notice "python3" at the end, but it didn't solve my problem. I still get the same error, i.e. it's still using Python 2.7.

@pmav99
Copy link
Contributor

pmav99 commented Nov 5, 2019

@jabbalaci you can create a virtualenv manually, activate it and then poetry will use that one. E.g.

python3 -mvenv ./.venv
./.venv/bin/activate
poetry ...

@jabbalaci
Copy link
Author

@pmav99 Thanks, but it's a workaround solution. If poetry wants to be better than pipenv, then it should just work out of the box.

@jabbalaci
Copy link
Author

OK, I found a way (using #721):

Install with Python 3:

curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python3

Then edit the file ~/.poetry/bin/poetry and change the first line to:

#!/usr/bin/env python3

That is, python is changed to python3.

The bad news is that if you update poetry to a new version, this change will be overwritten very likely.

@aizelauna
Copy link

Thanks for this solution.
It solved my issue similar to the #1257.

@RileyMShea
Copy link

Thanks @jabbalaci fixed my issue too.

@matthijskooijman
Copy link

I think this is essentially a duplicate of #721

@jabbalaci
Copy link
Author

@matthijskooijman Previously, I put a reference on #721 .

@danieleades
Copy link
Contributor

this workaround is not working for me on ubuntu 18.04

@jabbalaci
Copy link
Author

jabbalaci commented Dec 30, 2019

@danieleades Did you install it with python3? Notice that I have python3 at the end of this line:

curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python3

Under Ubuntu, python points to Python 2.

@danieleades
Copy link
Contributor

@jabbalaci yep.

@pmav99
Copy link
Contributor

pmav99 commented Dec 30, 2019

For the record, installing using pipx is probably much easier...
And this does not apply just to poetry but to any python utility that doesn't exist in the repos (and/or is outdated)

@finswimmer
Copy link
Member

finswimmer commented Dec 30, 2019

Hello @ all,

I'm closing this issue, because the original issue is resolved in poetry 1.0.

If poetry is installed with python2 and a pyproject.toml defines python3 as a dependency, poetry will try to find python3 for creating the venv. The same the other way round.

Furthermore, you can set the python executable, to use for the venv, with the new env subcommand, e.g. poetry env use python3.

More information are available in the docs.

@danieleades
Copy link
Contributor

Hi @finswimmer i've just tested this on ubuntu-
the same issue occurs if poetry is installed using python3, however the workaround now works (namely changing the shebang in /bin/poetry to "python3").

I don't think its fair to say the issue is completely resolved.

I didn't test installing with python2, it's practically 2020 after all ;)

@seanwu1105
Copy link

I faced the same issue when I try to install poetry on clean Ubuntu 18.04 as it does not install built-in python (2.x). By using the workaround (#!/usr/bin/env python3), I still could not use the poetry with the error messages on this issue.

@Jarmos-san
Copy link

Jarmos-san commented May 20, 2020

The issue is still very prevalent on Ubuntu 19.10, so I don't think so it's wise closing this issue yet. I tried @jabalacci's workaround, it installs fine but when I try checking if it installed properly using the poetry --version command, I get a poetry: command not found error.

Please look into it.

EDIT: Don't be a fool like me & jump to conclusions, curl it & when the download completes, make sure you run the source $HOME/.poetry/env command. Then check it using poetry --version.

@matthijskooijman
Copy link

Also: I think the problem reported in this issue has been fixed. If you run into new issues that happen to be on Ubuntu, better to open up a new issue (or look at other existing issues, such as #721 or #1837).

@McKenlly
Copy link

see env file into poetry hidden dir
export PATH="$HOME/.poetry/bin:$PATH"

Copy link

github-actions bot commented Mar 2, 2024

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

10 participants