Python:“错误的解释器:没有这样的文件或目录”当运行django-admin.py [英] Python: "bad interpreter: No such file or directory" when running django-admin.py
问题描述
我已经搞砸了这个,但我发现的所有解决方案似乎都解决了不是我的问题。
I've googled the hell out of this, but all of the solutions I've found seem to solve problems that are not mine.
我创建了一个项目在 / Users / [user] / Documents / projects / [project]
中的虚拟环境中,使用 virtualenv
并安装Django 。
I created a project in a virtual environment in /Users/[user]/Documents/projects/[project]
using virtualenv
and installed Django.
之后,我删除了该项目,并在虚拟环境之外的系统上安装了Django。现在,我试图运行这个:
Later, I deleted that project and installed Django on my system outside of the virtual environment. Now, I am trying to run this:
django-admin.py startproject mysite
但是,我收到此错误消息:
However, I am receiving this error message:
-bash: /usr/local/bin/django-admin.py:
/Users/[user]/Documents/projects/[project]/bin/python:
bad interpreter: No such file or directory
我发现我可以使这项工作的唯一方法是设置[项目]虚拟环境,就像我之前安装Django一样。
I have found that the only way I can make this work again is by setting up the [project] virtual environment as I had it before with Django installed in it.
我该如何解决?
推荐答案
我不知道你是如何做出这个错误的,但是你的修复是修改 / usr / local / bin / django-admin。 py
shebang 到# !/ usr / bin / env python
。
I'm not sure how you did to produce this error, but the fix for you is to change /usr/local/bin/django-admin.py
shebang to #!/usr/bin/env python
.
其实如果你在虚拟化中安装django这个 django-admin.py
将会shebang设置为您的virtualenv的python解释器,但此脚本不会在 / usr / local / bin /
中创建,而是将以 /< virtualenvpath> / bin /
以及 activate
和virtualenv python解释器,这是什么困惑我,除非你移动它!
Actually if you install django in a virtualenv the django-admin.py
will have the shebang set to the python interpreter of your virtualenv, but this script will not be created in /usr/local/bin/
instead it will be created in /<virtualenvpath>/bin/
along with activate
and the virtualenv python interpreter which is what confuse me, unless you moved it there !
这篇关于Python:“错误的解释器:没有这样的文件或目录”当运行django-admin.py的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!