【问题标题】:Django admin script not installed to PATHDjango 管理脚本未安装到 PATH
【发布时间】:2021-03-27 20:29:12
【问题描述】:

我在一台新电脑上,必须重新安装 Django,所以我在我的 VSCode 终端中输入了pip install Django 命令来安装它。但是,下载后,我收到以下消息:

  WARNING: The script django-admin.exe is installed in 'C:\Users\Xiaow\AppData\Roaming\Python\Python39\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

因此,我无法开始任何新项目。如何将此脚本安装到 PATH?有什么我必须做的命令吗?

'C:\Users\Xiaow' 中似乎还有一个 .vscode 文件夹,但我不知道这是否是导致 Django 无法将管理脚本安装到 PATH 的原因。

其他一切正常,例如我可以转到我现有的项目(从我的旧计算机复制)和运行服务器,并且可以访问所有数据库。但是,只是这个管理脚本导致了问题。我也尝试卸载并重新安装 Django 无济于事。

完整的终端消息:

PS C:\Code> pip install Django
Defaulting to user installation because normal site-packages is not writeable
Collecting Django
  Using cached Django-3.1.4-py3-none-any.whl (7.8 MB)
Requirement already satisfied: pytz in c:\users\xiaow\appdata\roaming\python\python39\site-packages (from Django) (2020.4)
Requirement already satisfied: sqlparse>=0.2.2 in c:\users\xiaow\appdata\roaming\python\python39\site-packages (from Django) (0.4.1)
Requirement already satisfied: asgiref<4,>=3.2.10 in c:\users\xiaow\appdata\roaming\python\python39\site-packages (from Django) (3.3.1)
Installing collected packages: Django
  WARNING: The script django-admin.exe is installed in 'C:\Users\Xiaow\AppData\Roaming\Python\Python39\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed Django-3.1.4

【问题讨论】:

    标签: python django installation pip


    【解决方案1】:

    我很确定您需要将脚本中的路径添加到环境变量列表中...您可以通过运行命令来实现。

    尝试在 windows 命令提示符下运行:

    set PATH=%PATH%;C:\Users\Xiaow\AppData\Roaming\Python\Python39\Scripts

    另外,这里是上面列出的命令的来源: Adding a directory to the PATH environment variable in Windows

    更新: 刚刚了解到set 命令仅设置当前会话的变量,因此如果您希望更改保持永久不变,请继续使用setx。

    【讨论】:

      猜你喜欢
      • 2020-04-07
      • 2021-07-20
      • 2018-05-28
      • 2013-05-30
      • 2014-10-29
      • 1970-01-01
      • 2013-04-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多