Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

codegabru
codegabru

Posted on

     

Using Python 3 with Poetry

This was originally posted on myHashnode blog.

Install Poetry:

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

The only problem is that for some reason Poetry doesn’t use Python version 3 by default for any project that you create using it and it doesn't run virtual environment shell using Python 3 even if the min required version of python is set to3.x for the project. Seeissue for more details.

A quick, safeand dirty (because you will have to do this every time you update Poetry version) way to fix this is given below.

Open~/.poetry/bin/poetry in editor of your choice. I’ll use nano :

nano ~/.poetry/bin/poetry

Top line of the file will be:

#!/usr/bin/env python

Update it to:

#!/usr/bin/env python3

Now Poetry should work as expected i.e run virtual environment shell using Python 3 etc.

Note: I think this will probably break things when you set min required version of Python to2.x for your project. I have not tested this for Python 2. Python 2 has been deprecated anyway. Let me know in the comments if there is a better way to do it.

Top comments(1)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
jjlorenzo profile image
jjlorenzo
  • Joined

I use pyenv and direnv without needing this fix

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

  • Joined

Trending onDEV CommunityHot

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp