[英]No name 'path' in module 'django.urls'
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. 我正在尝试使用AWS Cloud9建立Django项目-这是自从Cloud9移至AWS以来我第一次使用Cloud9,尽管我以前曾将其用于项目。 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. 我以为我创建的项目没有问题,但是urls.py中出现了与从django.urls导入“ path”有关的错误。 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. 我正在使用带有Python 3.6.8和Django 2.2.4的虚拟环境,但是由于此错误,当前无法运行该项目。 On a previous Cloud9 based project, I was using Django 2.1 with Python 3.6 and had no errors with this code. 在以前的基于Cloud9的项目中,我使用的是Django 2.1和Python 3.6,并且此代码没有错误。
This is all that is currently in urls.py: 这就是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
It looks like AWS is running django 1.11 or older. 看起来AWS正在运行django 1.11或更早版本。 path
was introduced starting django 2.0. 从django 2.0开始引入了path
。 check urls for version 2.0 检查版本2.0的网址
To check for version run this: 要检查版本,请运行以下命令:
python -m django --version
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.