django导入错误-没有名为core.management的模块

问题:django导入错误-没有名为core.management的模块

好的,我看到很多这些错误。我已经尝试了所有我想做的事情,但是还没有弄清楚。

我正在开发运行python 2.5和Django 1.3的开发服务器。在解压缩tar.gz下载文件后,使用python setup.py install安装了Django 1.3。

一切正常,我很少需要运行,manage.py但是正在尝试使用新的staticfiles应用程序,并且遇到了问题。

python manage.py collectstatic
Traceback (most recent call last):
  File "manage.py", line 2, in <module>
    from django.core.management import execute_manager
ImportError: No module named core.management

好的,所以我有PATH问题。

Django安装中,我再次检查site-packages目录。

python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
/usr/lib/python2.5/site-packages

好的,让我们检查一下我拥有的东西,echo $ PYTHON_PATH为空,所以我将其设置为

export PYTHON_PATH=/usr/lib/python2.5/site-packages/django

仍然没有运气。让我们检查sys.path怎么说

>>> import sys
>>> print sys.path
['', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages/PIL', '/usr/lib/python2.5/site-packages/django', '/var/lib/python-support/python2.5']

路径在那里,我什至用内容创建了/usr/lib/python2.5/site-packages/django.pth

cat /usr/lib/python2.5/site-packages/django.pth 
/usr/lib/python2.5/site-packages/django/

有人知道这里发生了什么吗?

我在通往的道路上发现了一个符号链接,但没有出现新的错误。

python manage.py collectstatic
Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    execute_manager(settings)
  File "/usr/lib/python2.5/site-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/usr/lib/python2.5/site-packages/django/core/management/__init__.py", line 349, in execute
    version=get_version(),
  File "/usr/lib/python2.5/site-packages/django/__init__.py", line 12, in get_version
    from django.utils.version import get_svn_revision
ImportError: No module named utils.version

我还尝试创建一个新项目,以查看是否存在任何问题,并得到相同的utils.version错误。

侧面节点:#django的Unode帮助了我一点,在同一台计算机上设置了virtualenv并克服了错误,因此仍不确定此处的实际安装如何,但是似乎不在django项目中,而在django中/ python安装。

Ok, I see plenty of these errors around. I have tried everything I know to do and have yet to figure this out.

I am working on a development server running python 2.5 and Django 1.3. Django 1.3 was installed using python setup.py install after unpacking the tar.gz download.

All works well, I seldom have the need to run manage.py but am trying to use the new staticfiles app and am running into problems.

python manage.py collectstatic
Traceback (most recent call last):
  File "manage.py", line 2, in <module>
    from django.core.management import execute_manager
ImportError: No module named core.management

Ok, so I have PATH issue.

From Django install I double check my site-packages directory.

python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
/usr/lib/python2.5/site-packages

Ok, let’s check out what I have, echo $PYTHON_PATH was empty, so I set it

export PYTHON_PATH=/usr/lib/python2.5/site-packages/django

Still no luck. Lets check what sys.path has to say

>>> import sys
>>> print sys.path
['', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages/PIL', '/usr/lib/python2.5/site-packages/django', '/var/lib/python-support/python2.5']

path is there, I even created /usr/lib/python2.5/site-packages/django.pth with contents

cat /usr/lib/python2.5/site-packages/django.pth 
/usr/lib/python2.5/site-packages/django/

Anyone got an clues to what is going on here?

I found a symlink further up the path that was getting in the way, but no on to a new error.

python manage.py collectstatic
Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    execute_manager(settings)
  File "/usr/lib/python2.5/site-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/usr/lib/python2.5/site-packages/django/core/management/__init__.py", line 349, in execute
    version=get_version(),
  File "/usr/lib/python2.5/site-packages/django/__init__.py", line 12, in get_version
    from django.utils.version import get_svn_revision
ImportError: No module named utils.version

I also tried creating a new project to see if there were any issues there and get the same utils.version error.

Side node: Unode from #django helped me a bit, set up virtualenv on same machine and got past the errors so still not sure what is up with this actual install here, but it seems to not be in the django projects but in the django/python install.


回答 0

如果像我一样,您正在virtualenv中运行django,并收到此错误,请查看您的manage.py。第一行应定义用于运行脚本的python可执行文件。这应该是您的virtualenv的python的路径,但这是/ usr / bin / python之类的错误,它不是相同的路径,并且将使用全局python环境(并且缺少软件包)。只需将路径更改为virtualenv中python可执行文件的路径即可。

您也可以用替换您的shebang线#!/usr/bin/env python。如果您首先激活了virtualenv,这应该使用适当的python环境和解释器(我假设您知道如何执行此操作)。

If, like me, you are running your django in a virtualenv, and getting this error, look at your manage.py. The first line should define the python executable used to run the script. This should be the path to your virtualenv’s python, but it is something wrong like /usr/bin/python, which is not the same path and will use the global python environment (and packages will be missing). Just change the path into the path to the python executable in your virtualenv.

You can also replace your shebang line with #!/usr/bin/env python. This should use the proper python environment and interpreter provided that you activate your virtualenv first (I assume you know how to do this).


回答 1

如果您在virtualenv中,则需要先激活它,然后才能运行./manage.py’command’

source path/to/your/virtualenv/bin/activate

如果您在.bash_profile或.bashrc中配置workon

workon yourvirtualenvname

*请不要编辑您的manage.py文件,可能不是正确的方法,并且可能会给您将来的错误

If you are in a virtualenv you need to activate it before you can run ./manage.py ‘command’

source path/to/your/virtualenv/bin/activate

if you config workon in .bash_profile or .bashrc

workon yourvirtualenvname

*please dont edit your manage.py file maybe works by isnt the correct way and could give you future errors


回答 2

我遇到了同样的问题,因为我以超级用户身份安装Django,因此不在我的virtualenv中。你不应该做sudo pip install Django

而是以这种方式安装它:

$ source ./bin/activate
$ pip install Django

I had the same problem because I was installing Django as a super user, thus not in my virtualenv. You should not do sudo pip install Django

Instead, install it this way:

$ source ./bin/activate
$ pip install Django

回答 3

请用pip重新安装django:

sudo pip install --upgrade django==1.3

(将1.3替换为您的Django版本)

Please, reinstall django with pip:

sudo pip install --upgrade django==1.3

(Replace 1.3 to your django version)


回答 4

众所周知,这是一个路径问题。

我的自定义软件包的基础与/ etc / profile中设置的目录共享一个名称。软件包位于Web服务器的其他位置。因此,我从$ PYTHONPATH中删除了令人反感的条目,并且一切顺利!

谢谢您的帮助。

As known this was a path issue.

the base of my custom packages shared a name with a directory set in a /etc/profile. The packages were in a different location however for the webserver. So I removed the offending entries from my $PYTHONPATH and was good to go!

Thanks for the help.


回答 5

此问题的另一个可能原因是,您的操作系统默认情况下运行python3。

您必须明确地执行以下操作: python2 manage.py

或您需要编辑的shebang manage.py,如下所示:

#!/usr/bin/env python2

或者,如果您使用的是python3:

#!/usr/bin/env python3

Another possible reason for this problem is that your OS runs python3 by default.

Either you have to explicitly do: python2 manage.py

or you need to edit the shebang of manage.py, like so:

#!/usr/bin/env python2

or if you are using python3:

#!/usr/bin/env python3

回答 6

而试图在运行嵌入式系统(当然使用Django的)我有这个错误树莓派2(并且不是一个VM

运行此:

 sudo pip install Django

搞定了!

  • 以防万一使用Raspbian / Jessie的人得到了这个

I had this error while trying to run an embedded system (using django of course) on a Raspberry Pi 2 (and not a VM)

Running this:

 sudo pip install Django

Made the trick!

  • just in case a fellow using Raspbian/Jessie gets this

回答 7

您可能正在使用virtualenvwrapper。不要忘记通过运行以下命令来选择您的环境:

$ workon env_name

You are probably using virtualenvwrapper. Don’t forget to select your enviroment by running:

$ workon env_name

回答 8

对我来说,我的服务器使用的是Python 2.4。我只是查找了安装在服务器上的Python 2.7,并创建了一个别名。

alias python=python2.7

如果您需要了解更多信息,我在这里找到了解决方案

For me, my server was using Python 2.4. I simply looked up Python 2.7, which was installed on my server, and created an alias.

alias python=python2.7

If you need to know more, I found the solution here


回答 9

尝试创建新应用时遇到了同样的问题。如果您编写python manage.py startapp myapp,则它将查找usr / bin / python。但是您需要这个“ python ”,它位于虚拟环境路径的/ bin目录中。我通过提及virtualenv的python路径来解决此问题,如下所示:

<env path>/bin/python manage.py startapp myapp

I was getting the same problem while I trying to create a new app. If you write python manage.py startapp myapp, then it looks for usr/bin/python. But you need this “python” which is located in /bin directory of your virtual env path. I solved this by mentioning the virtualenv’s python path just like this:

<env path>/bin/python manage.py startapp myapp

回答 10

尝试更改您的manage.py的第一行。

更改

#!/usr/bin/python

通过

#!/usr/bin/env python

Try change your first line of manage.py.

Change

#!/usr/bin/python

by

#!/usr/bin/env python

回答 11

python3 manage.py runserver

检查Python版本

python3 manage.py runserver

Check version of Python


回答 12

解决了!!!

在寻找了年龄并尝试了所有其他不可行的建议之后,我终于找到了适合我的设置的解决方案。

我的设置/方案:

  • Windows,Python27
  • 我的Django项目通过svn签出
  • 在新文件夹中运行python manage.py runserver时,出现导入错误
  • python manage.py runserver曾经在原始文件夹(我会提交更改)中使用,直到删除它为止

删除manage.py同一目录中名为django的所有文件夹

没错…删除文件夹“ django”后,该文件夹仅包含__init__.py文件…我可以再次运行服务器!

不知道为什么

Solved it!!!

After searching for ages and trying all these other suggestions which didn’t work, I finally found the solution for my setup.

My setup/scenario:

  • Windows, Python27
  • My django project is checked out via svn
  • when running python manage.py runserver in the new folder, I got the import error
  • python manage.py runserver used to work in the original folder (which I would commit changes from) until I deleted it

Solution

Remove any the folder named django in the same directory of manage.py

Thats right…as soon as I removed the folder “django” which only contained a __init__.py file…I could run the server again!

Have no idea why though


回答 13

对于使用Django 1.6或更高版本的用户,请注意execute_manager已删除。有张贴在第二SO答案的解决方案在这里

For those of you using Django 1.6 or newer, note that execute_manager was removed. There is a solution posted in the second SO answer here.


回答 14

将python python路径存储在一个变量中并执行。

python_path= `which python` 
$python_path manage.py runserver

Store the python python path in a variable and execute.This would include the otherwise missing packages.

python_path= `which python` 
$python_path manage.py runserver

回答 15

我有一个类似的问题。PyCharm无法运行服务器,但是我可以从命令行运行它。我尝试使用哪个python,然后确保PyCharm是相同的解释器,然后一切正常。

I had a similar problem. PyCharm couldn’t run the server but I could run it from the command line. I tried which python and then made sure that PyCharm was same interpreter and then everything worked OK.


回答 16

当未安装django时,通常会发生此错误。如果您已经安装了django但仍然遇到相同的错误,则必须在单独的虚拟环境中工作。您还需要在虚拟环境中安装django。当您在虚拟机的外壳中时,只需执行以下操作:

pip安装Django

这是因为虚拟机具有单独的文件系统,即使将Django安装在您的系统上,它也无法识别。

This error usually occurs when django is not installed. If you have already installed django but still getting the same error, then you must be working in separate virtual environment. You need to install django in your virtual environmnent as well. When you are in shell of virtual machine simply do this:

pip install django

It is because virtual machine has separate file system, it doesn’t recognize django even if it is installed on your system.


回答 17

我通过将#PATH =“ $ VIRTUAL_ENV / bin:$ PATH”更改为PATH =“ $ PATH:$ VIRTUAL_ENV / bin”来解决此问题,由于对我不明显的原因,virtualenv目录中的python可执行文件看不到Django,但安装的Python呢。

I fixed this problem by changing #PATH=”$VIRTUAL_ENV/bin:$PATH” to PATH=”$PATH:$VIRTUAL_ENV/bin” For reasons not obvious to me the python executable in the virtualenv dir does not see django but the normally installed python does.


回答 18

================================解决方案=============== =========================

首先转到:virtualenv

通过运行以下命令:source bin / activate

并安装django,因为您收到与“ import django”相关的错误:

pip install django

然后运行:

python manage.py runserver

(注意:请将“ runserver”更改为要运行的程序名称)

对于同一问题,它在我的情况下有效。=================================提要================= =========================

ERROR:
(Development) Rakeshs-MacBook-Pro:src rakesh$ python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    import django
ModuleNotFoundError: No module named 'django'

在处理上述异常期间,发生了另一个异常:

Traceback (most recent call last):
  File "manage.py", line 17, in <module>
    "Couldn't import Django. Are you sure it's installed and "
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
(Development) Rakeshs-MacBook-Pro:src rakesh$ 
(Development) Rakeshs-MacBook-Pro:src rakesh$ 
(Development) Rakeshs-MacBook-Pro:src rakesh$ python -Wall manage.py test
Traceback (most recent call last):
  File "manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'

在处理上述异常期间,发生了另一个异常:

Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    import django
ModuleNotFoundError: No module named 'django'

在处理上述异常期间,发生了另一个异常:

Traceback (most recent call last):
  File "manage.py", line 17, in <module>
    "Couldn't import Django. Are you sure it's installed and "
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?

安装Django之后:

(Development) MacBook-Pro:src rakesh$ pip install django
Collecting django
  Downloading https://files.pythonhosted.org/packages/51/1a/e0ac7886c7123a03814178d7517dc822af0fe51a72e1a6bff26153103322/Django-2.1-py3-none-any.whl (7.3MB)
    100% |████████████████████████████████| 7.3MB 1.1MB/s 
Collecting pytz (from django)
  Downloading https://files.pythonhosted.org/packages/30/4e/27c34b62430286c6d59177a0842ed90dc789ce5d1ed740887653b898779a/pytz-2018.5-py2.py3-none-any.whl (510kB)
    100% |████████████████████████████████| 512kB 4.7MB/s 
Installing collected packages: pytz, django

解决后:

(Development) MacBook-Pro:src rakesh$ python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).

You have 15 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.

August 05, 2018 - 04:39:02
Django version 2.1, using settings 'trydjango.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[05/Aug/2018 04:39:15] "GET / HTTP/1.1" 200 16348
[05/Aug/2018 04:39:15] "GET /static/admin/css/fonts.css HTTP/1.1" 200 423
[05/Aug/2018 04:39:15] "GET /static/admin/fonts/Roboto-Bold-webfont.woff HTTP/1.1" 200 82564
[05/Aug/2018 04:39:15] "GET /static/admin/fonts/Roboto-Light-webfont.woff HTTP/1.1" 200 81348
[05/Aug/2018 04:39:15] "GET /static/admin/fonts/Roboto-Regular-webfont.woff HTTP/1.1" 200 80304
Not Found: /favicon.ico
[05/Aug/2018 04:39:16] "GET /favicon.ico HTTP/1.1" 404 1976

祝好运!!

==================================SOLUTION=========================================

First goto: virtualenv

by running the command: source bin/activate

and install django because you are getting the error related to ‘import django’:

pip install django

Then run:

python manage.py runserver

(Note: please change ‘runserver’ to the program name you want to run)

For the same issue, it worked in my case. ==================================Synopsis=========================================

ERROR:
(Development) Rakeshs-MacBook-Pro:src rakesh$ python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    import django
ModuleNotFoundError: No module named 'django'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 17, in <module>
    "Couldn't import Django. Are you sure it's installed and "
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
(Development) Rakeshs-MacBook-Pro:src rakesh$ 
(Development) Rakeshs-MacBook-Pro:src rakesh$ 
(Development) Rakeshs-MacBook-Pro:src rakesh$ python -Wall manage.py test
Traceback (most recent call last):
  File "manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    import django
ModuleNotFoundError: No module named 'django'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 17, in <module>
    "Couldn't import Django. Are you sure it's installed and "
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?

AFTER INSTALLATION of django:

(Development) MacBook-Pro:src rakesh$ pip install django
Collecting django
  Downloading https://files.pythonhosted.org/packages/51/1a/e0ac7886c7123a03814178d7517dc822af0fe51a72e1a6bff26153103322/Django-2.1-py3-none-any.whl (7.3MB)
    100% |████████████████████████████████| 7.3MB 1.1MB/s 
Collecting pytz (from django)
  Downloading https://files.pythonhosted.org/packages/30/4e/27c34b62430286c6d59177a0842ed90dc789ce5d1ed740887653b898779a/pytz-2018.5-py2.py3-none-any.whl (510kB)
    100% |████████████████████████████████| 512kB 4.7MB/s 
Installing collected packages: pytz, django

AFTER RESOLVING:

(Development) MacBook-Pro:src rakesh$ python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).

You have 15 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.

August 05, 2018 - 04:39:02
Django version 2.1, using settings 'trydjango.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[05/Aug/2018 04:39:15] "GET / HTTP/1.1" 200 16348
[05/Aug/2018 04:39:15] "GET /static/admin/css/fonts.css HTTP/1.1" 200 423
[05/Aug/2018 04:39:15] "GET /static/admin/fonts/Roboto-Bold-webfont.woff HTTP/1.1" 200 82564
[05/Aug/2018 04:39:15] "GET /static/admin/fonts/Roboto-Light-webfont.woff HTTP/1.1" 200 81348
[05/Aug/2018 04:39:15] "GET /static/admin/fonts/Roboto-Regular-webfont.woff HTTP/1.1" 200 80304
Not Found: /favicon.ico
[05/Aug/2018 04:39:16] "GET /favicon.ico HTTP/1.1" 404 1976

Good luck!!


回答 19

您的项目是使用django1.3之前的旧版本django-admin.py创建的

要解决此问题,请创建另一个django项目并复制其manage.py并将其粘贴到旧的项目中

your project is created using an old version of django-admin.py, older than django1.3

to fix this create another django project and copy its manage.py and paste it in the old one


回答 20

完全同意这是一个路径问题,但是首先,我遇到了同样的错误。这是由于在设置虚拟环境时为我的Python可执行文件使用了相对路径的错误。我这样做了:

virtualenv -p ~/python_runtimes/2.7.3/bin/python venv2.7.3 --distribute

相反,我不得不给出Python可执行文件的完整路径。

哈林HTH

Agreed completely that this is a path issue but fwiw, I had this same error. It was due to the mistake of using a relative path for my Python executable when setting up my virtual environment. I had done this:

virtualenv -p ~/python_runtimes/2.7.3/bin/python venv2.7.3 --distribute

Instead I had to give the full path to the Python executable.

HTH, Harlin


回答 21

来源〜/ blog-venv / bin / activate

在此处选择您的virtualenv替换“ blog-venv”。

source ~/blog-venv/bin/activate

pick your virtualenv to replace “blog-venv” here.


回答 22

确保您在路径上使用正确的目录运行正确的Python实例。就我而言,此错误是python由偶然运行可执行文件引起的-我实际上是在python2.7框架和库下安装了Django 。由于virtualenv也可能发生相同的情况。

Be sure you’re running the right instance of Python with the right directories on the path. In my case, this error resulted from running the python executable by accident – I had actually installed Django under the python2.7 framework & libraries. The same could happen as a result of virtualenv as well.


回答 23

好的,它像这样:

您已经创建了一个虚拟环境,而django模块仅属于该环境。由于virtualenv会将其自身与其他所有事物隔离开,因此您会看到这一点。

进行以下操作以获得进一步的帮助:

http://www.swegler.com/becky/blog/2011/08/27/python-django-mysql-on-windows-7-part-i-getting-started/

1.您可以切换到虚拟环境存储的目录,然后运行django模块。

2.或者您可以通过运行pip或easy_install将django全局安装到python-> site-packages

使用pip的命令:pip install django

然后这样做:

导入django打印(django.get_version())(取决于您使用的python版本。这适用于python 3+系列)

然后您可以运行以下命令:python manage.py runserver并通过输入:localhost:8000在Web浏览器上进行检查,您应该看到django驱动的页面。

希望这可以帮助。

Okay so it goes like this:

You have created a virtual environment and django module belongs to that environment only.Since virtualenv isolates itself from everything else,hence you are seeing this.

go through this for further assistance:

http://www.swegler.com/becky/blog/2011/08/27/python-django-mysql-on-windows-7-part-i-getting-started/

1.You can switch to the directory where your virtual environment is stored and then run the django module.

2.Alternatively you can install django globally to your python->site-packages by either running pip or easy_install

Command using pip: pip install django

then do this:

import django print (django.get_version()) (depending on which version of python you use.This for python 3+ series)

and then you can run this: python manage.py runserver and check on your web browser by typing :localhost:8000 and you should see django powered page.

Hope this helps.


回答 24

我在发出startapp命令之前“之前”将新应用程序的名称包含在settings.py的INSTALLED_APPS列表中。删除列表条目后,就可以创建应用了。

I included the name of the new App to the INSTALLED_APPS list in the settings.py “before” I issued the startapp command. Once I removed the list entry, I could create the app.


回答 25

我通过使用’django-admin’命令来解决此问题,如下所示:

django-admin startproject _project_name

只需删除附加到“ django-admin”的“ .py”

I solved this problem by using ‘django-admin’ command as following instead:

django-admin startproject _project_name

just remove the “.py” attached to “django-admin”


回答 26

调用一个应用程序site也可以重现此问题。

Having an application called site can reproduce this issue either.


回答 27

我之所以忘记了,是因为我忘记使用来安装Django pip -U,因此它仅适用于运行Django应用的用户。要运行manage.py我必须做

sudo su -s /bin/bash MY_DJANGO_USER
/PATH/TO/MY/APP/manage.py

I got this due to forgetting that I installed Django using pip -U, so it was only available to the user running my Django app. To run manage.py I had to do

sudo su -s /bin/bash MY_DJANGO_USER
/PATH/TO/MY/APP/manage.py

回答 28

你们所有人都没有提到有人“像我”会在安装virtualenv之前安装django …因此,对于所有此类人,如果这样做,…在激活virtualenv..i之后重新安装django。希望这可以帮助

all of you guys didn’t mention a case where someone “like me” would install django befor installing virtualenv…so for all the people of my kind ther if you did that…reinstall django after activating the virtualenv..i hope this helps