简体   繁体   English

django-admin startproject在OS X上无法与python3一起使用

[英]django-admin startproject not working with python3 on OS X

I have python3 installed with Django 1.8.2 on Mac OS. 我在Mac OS上的Django 1.8.2上安装了python3。 There is also python 2.7 installed by default with the OS. 默认情况下,操作系统还安装了python 2.7。 When trying to run startproject I get - 尝试运行startproject时,我得到-

$ django-admin startproject mysite
Traceback (most recent call last):
  File "/usr/local/bin/django-admin", line 7, in <module>
    from django.core.management import execute_from_command_line
ImportError: No module named django.core.management

It is likely defaulting to the system's python 2.7 which does not have django. 它可能是默认的系统python 2.7,没有django。 How do I force it to use python3? 如何强制使用python3? I tried aliasing python to python3 in the shell but that didn't work either. 我尝试在外壳程序中将python别名为python3,但是那也不起作用。

Recommended: Try using virtualenv and initiate your environment with Python3. 推荐:尝试使用virtualenv并使用Python3初始化环境。

Or a quicker solution is to use python interpreter directly to execute django-admin: 或更快捷的解决方案是直接使用python解释器执行django-admin:

<path-to-python3>/python /usr/local/bin/django-admin startproject mysite

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM