Open pyx opened 1 year ago
Confirmed. This appears to be an upstream issue with tracerite
[💻 ssadowski@q|test-sanic]$ pdm run sanic
Traceback (most recent call last):
File "/playground/test-sanic/.venv/bin/sanic", line 5, in <module>
from sanic.__main__ import main
File "/playground/test-sanic/.venv/lib/python3.11/site-packages/sanic/__init__.py", line 6, in <module>
from sanic.app import Sanic
File "/playground/test-sanic/.venv/lib/python3.11/site-packages/sanic/app.py", line 55, in <module>
from sanic.application.state import ApplicationState, ServerStage
File "/playground/test-sanic/.venv/lib/python3.11/site-packages/sanic/application/state.py", line 13, in <module>
from sanic.server.async_server import AsyncioServer
File "/playground/test-sanic/.venv/lib/python3.11/site-packages/sanic/server/__init__.py", line 5, in <module>
from sanic.server.runners import serve
File "/playground/test-sanic/.venv/lib/python3.11/site-packages/sanic/server/runners.py", line 6, in <module>
from sanic.config import Config
File "/playground/test-sanic/.venv/lib/python3.11/site-packages/sanic/config.py", line 13, in <module>
from sanic.errorpages import DEFAULT_FORMAT, check_error_format
File "/playground/test-sanic/.venv/lib/python3.11/site-packages/sanic/errorpages.py", line 26, in <module>
from sanic.pages.error import ErrorPage
File "/playground/test-sanic/.venv/lib/python3.11/site-packages/sanic/pages/error.py", line 3, in <module>
import tracerite.html
File "/playground/test-sanic/.venv/lib/python3.11/site-packages/tracerite/__init__.py", line 1, in <module>
import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'
Tagging in @Tronic and it may make sense to open a correlating issue there.
Looks like it is missing setuptools (where that module comes from). Normally Python comes with that installed, but in virtual envs it is apparently not available. Can you try pip install setuptools
manually within PDM virtual env and report back?
If that fixes it, we are just missing that dependency in tracerite.
I added setuptools and it failed without error (correctly, I might add, because there's nothing for it to actually run yet) so I'd say that seems to be accurate. I'll create a quick stub for sanic after work and verify.
Looks like it is missing setuptools (where that module comes from). Normally Python comes with that installed, but in virtual envs it is apparently not available. Can you try
pip install setuptools
manually within PDM virtual env and report back?If that fixes it, we are just missing that dependency in tracerite.
Yes, you are correct. After pdm add setuptools
, it works fine.
Fixed (not tested) on Tracerite git now. Needs a new tracerite release, @ahopkins can you push one out?
@Tronic
I am trying to revitalize some of my sanic plugin projects, and found this, it mentioned Tracerite
, seems to be related, you might find it interesting.
$ pdm run pytest tests/
============================= test session starts =============================
platform linux -- Python 3.11.5, pytest-7.4.2, pluggy-1.2.0
rootdir: /home/pyx/projects/sanic-wtf
plugins: anyio-3.7.1, cov-4.1.0
collected 12 items
tests/test_form.py ........ [ 66%]
tests/test_utils.py . [ 75%]
tests/test_validators.py ... [100%]
============================== warnings summary ===============================
.venv/lib/python3.11/site-packages/tracerite/__init__.py:1
/home/pyx/projects/sanic-wtf/.venv/lib/python3.11/site-packages/tracerite/__init__.py:1: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
import pkg_resources
.venv/lib/python3.11/site-packages/pkg_resources/__init__.py:2871
.venv/lib/python3.11/site-packages/pkg_resources/__init__.py:2871
.venv/lib/python3.11/site-packages/pkg_resources/__init__.py:2871
.venv/lib/python3.11/site-packages/pkg_resources/__init__.py:2871
.venv/lib/python3.11/site-packages/pkg_resources/__init__.py:2871
.venv/lib/python3.11/site-packages/pkg_resources/__init__.py:2871
/home/pyx/projects/sanic-wtf/.venv/lib/python3.11/site-packages/pkg_resources/__init__.py:2871: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('sphinxcontrib')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
declare_namespace(pkg)
.venv/lib/python3.11/site-packages/websockets/connection.py:9
/home/pyx/projects/sanic-wtf/.venv/lib/python3.11/site-packages/websockets/connection.py:9: DeprecationWarning: websockets.connection was renamed to websockets.protocol and Connection was renamed to Protocol
warnings.warn(
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
Upcoming tracerite-1.1.1 (git main) no longer uses pkg_resources
so this issue is resolved for good. Still needs Tracerite pypi release and then Sanic depending on the new one.
Tracerite 1.1.1 still depends on pkg_resources
so I still get this error.
Tracerite 1.1.1 still depends on
pkg_resources
so I still get this error.
Sorry about that. Can you try if the PR solves this issue so we could get that released as another version... https://github.com/sanic-org/tracerite/pull/10
confirmed still an issue with sanic v23.12.1 as of Feb 13, 2024.
installing setuptools to the virtualenv fixed the issue for me.
edit: I was not using PDM, just new virtualenv, pip install sanic
, copy the hello world code, and sanic server
and got the error, until i added setuptools
to the virtualenv.
Is there an existing issue for this?
Describe the bug
As mentioned in the the book Python Web Developmentwith Sanic, I installed sanic with pdm:
It failed with:
ModuleNotFoundError: No module named 'pkg_resources'
Same error within virtual environment created by pdm as:
python version 3.11 sanic version 23.6.0 pdm version 2.9.2
Code snippet
No response
Expected Behavior
Should be able to run sanic CLI, it worked with virtual environment I created manually.
How do you run Sanic?
Sanic CLI
Operating System
Linux
Sanic Version
23.6.0
Additional context
No response