django-admin启动项目错误(版本冲突?)

zbdgwd5y  于 2023-01-10  发布在  Go
关注(0)|答案(1)|浏览(148)

When I run "django-admin startproject myproject" I get the following error: Traceback (most recent call last): File "/System/Volumes/Data/Library/Frameworks/Python.framework/Versions/3.11/bin/django-admin", line 5, in from django.core.management import execute_from_command_line File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/django/core/management/init.py", line 17, in from django.conf import settings File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/django/conf/init.py", line 14, in from pathlib import Path File "/opt/anaconda3/lib/python3.9/site-packages/pathlib.py", line 10, in from collections import Sequence ImportError: cannot import name 'Sequence' from 'collections' (/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/collections/init.py)
我假设这个问题是由于涉及多个位置和版本的问题。这似乎是正确的假设吗?如何解决这个问题的建议?

ckx4rj1h

ckx4rj1h1#

我想你猜对了,你有多个版本的python,这里的错误是你应该在Django项目中为python创建一个虚拟环境,然后激活它。
1.打开终端并导航到要创建虚拟环境的目录。
1.运行以下命令创建新的虚拟环境:第一个月
1.通过运行以下命令激活虚拟环境:source myenv/bin/activate
1.运行以下命令在虚拟环境中安装Django:pip install django
1.运行django-admin startproject命令来创建Django项目,这样可以让你创建的Django项目没有任何冲突。

相关问题