2

I'm trying to set up a Django project using AWS Cloud9 - this is the first time I have used Cloud9 since it moved to AWS, although I had used it for projects previously. I thought I had created the project with no problems, but I am getting a error in urls.py relating to the import of 'path' from django.urls. A warning on the page says:

No name 'path' in module 'django.urls'

I am using a virtual environment with Python 3.6.8 and Django 2.2.4, but currently I cannot run the project because of this error. On a previous Cloud9 based project, I was using Django 2.1 with Python 3.6 and had no errors with this code.

This is all that is currently in urls.py:

from django.contrib import admin
from django.urls import path

urlpatterns = [
    path('admin/', admin.site.urls),
]

Trying to run the project, I get this error:

Traceback (most recent call last):
  File "/home/ec2-user/environment/project/urls.py", line 17, in <module>
    from django.urls import path
ImportError: cannot import name path

1 Answers1

0

It looks like AWS is running django 1.11 or older. path was introduced starting django 2.0. check urls for version 2.0

To check for version run this:

python -m django --version
Ramy M. Mousa
  • 5,727
  • 3
  • 34
  • 45