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.10Virtualenv
Python: 3.10.6
Implementation: CPython
Path: /opt/render/project/src/.venv
Valid: TrueSystem
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 filePackage 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
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.