https://pantsbuild.org/ logo
#general
Title
# general
a

adventurous-tiger-49478

03/07/2023, 10:14 AM
Need some help. When I try to run a django server using pants, I get a persistent error.
./pants run fleet_backend:manage -- runserver                                                                     ─╯
131030.41 [INFO] Completed: Building local_dists.pex 131043.88 [INFO] Completed: Building fleet_backend/manage.pex with 3 requirements: Django==4.1.7, django-stubs>=1.10.0, python-dotenv Traceback (most recent call last): File "/home/kalungi/projects/fleet-backend/fleet_backend/manage.py", line 10, in main from django.core.management import execute_from_command_line ModuleNotFoundError: No module named 'django' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib/python3.9/runpy.py", line 87, in _run_code exec(code, run_globals) File "/home/kalungi/projects/fleet-backend/fleet_backend/manage.py", line 21, in <module> main() File "/home/kalungi/projects/fleet-backend/fleet_backend/manage.py", line 12, in main raise ImportError( ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
p

polite-garden-50641

03/07/2023, 3:48 PM
try running the
dependencies
goal with the
--dependencies-transitive
option to see if pants sees that this target (fleet_backend:manage) depends on Django. so:
./pants dependencies --dependencies-transitive fleet_backend:manage
if you are using Django make sure you turned on string based dependency inference. https://www.pantsbuild.org/docs/reference-python-infer#string_imports
a

adventurous-tiger-49478

03/07/2023, 4:01 PM
I resolved the issue. Thanks for your advice nonetheless