Poetry doens't use chosen python version

Hi everyone,

I followed the Deploy Django tutorial but I have some problems deploying it to render.com.

The website works properly in localhost, but when deploying, python versions in poetry get entangled. I’m trying to use Django 4.1.1 and Python 3.10.6. I specified PYTHON_VERSION environment variable to 3.10.6, but Poetry tries to use 3.7.10 while using 3.10.6 for venv only. I think the build fails because of this and would like some help please.

Here are the build logs (I don’t know how to make it scrollable sorry):

==> Downloading cache…
==> Transferred 30MB in 11s. Extraction took 1s.
==> Using Python version: 3.10.6
==> Running build command ‘./build.sh’…

Poetry
Version: 1.1.11
Python: 3.7.10

Virtualenv
Python: 3.10.6
Implementation: CPython
Path: /opt/render/project/src/.venv
Valid: True

System
Platform: linux
OS: posix
Python: /opt/render/project/python/Python-3.10.6
/opt/render/project/src/.venv/bin/python
/opt/render/project/src/.venv/bin/python3
Using virtualenv: /opt/render/project/src/.venv
Installing dependencies from lock file

Package operations: 6 installs, 0 updates, 1 removal

• Removing setuptools (65.3.0)
• Installing asgiref (3.5.2)
• Installing brotli (1.0.9)
• Installing sqlparse (0.4.2)
• Installing django (4.1.1)
• Installing gunicorn (20.1.0)
• Installing whitenoise (6.2.0)

ValueError

/opt/render/project/src/[masked] does not contain any element

at /home/render/.python-poetry/venv/lib/python3.7/site-packages/poetry/core/masonry/utils/package_include.py:61 in check_elements
57│
58│ def check_elements(self): # type: () → PackageInclude
59│ if not self._elements:
60│ raise ValueError(
61│ “{} does not contain any element”.format(self._base / self._include)
62│ )
63│
64│ root = self._elements[0]
65│ if len(self._elements) > 1:
==> Build failed :disappointed:

As you can read, the building script tries to use python 3.10.6. Poetry version is 1.1.11 although 1.2.1 is out. Finally, Poetry tries to use Python 3.7.10 but says it uses 3.10.6 for venv, which seems weird.

Lastly, just before line 57, we see that the python path uses 3.7. I think this is why the building is failing, since it should be 3.10.

I don’t know if the problem comes from Poetry version or somewhere else. It would be nice to have Poetry 1.2.1 to experiment, since that’s what I use on my machine.

2 Likes

Hi there,
Could you try setting the version Poetry uses manually

poetry env use PYTHON_VERSION

and see if that helps things here?

John B

Hello,

I already tried using poetry env use 3.10. I had it when I captured the log in the first message.

I downgraded everything to try another version but I have the same problem. I’m starting to believe my project structure isn’t correct. I’ll check into that.

By the way I tried following the Django tutorial step by step and the site doesn’t deploy (I can’t see the error message).

There was a weird include line in pyproject.toml: packages = [{include = "[mypackage]"}]

I don’t know how it got there, considering there’s no such line on the tutorial files. I removed it and fixed some other stuff, and now the building and deployment pass, but my website is all white. I’ll look into that on my own.

Last question: Is there a way to change Poetry version ? I’d like to use 1.2.1 (the latest)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.