简体   繁体   English

在Mac上安装Django的正确方法是什么

[英]What's the correct way to install Django on mac

My mac has 2.7 python. 我的Mac有2.7 python。 I downloaded the latest version which is 3.5. 我下载了最新版本3.5。 Next I installed pip. 接下来,我安装了pip。 I then tried to install Django, but when I do I am thrown the following error 然后,我尝试安装Django,但是当我这样做时,抛出以下错误

 Traceback (most recent call last):
      File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/basecommand.py", line 211, in main
        status = self.run(options, args)
      File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/commands/install.py", line 311, in run
        root=options.root_path,
      File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/req/req_set.py", line 646, in install
        **kwargs
      File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/req/req_install.py", line 803, in install
        self.move_wheel_files(self.source_dir, root=root)
      File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/req/req_install.py", line 998, in move_wheel_files
        isolated=self.isolated,
      File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/wheel.py", line 339, in move_wheel_files
        clobber(source, lib_dir, True)
      File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/wheel.py", line 310, in clobber
        ensure_dir(destdir)
      File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/utils/__init__.py", line 71, in ensure_dir
        os.makedirs(path)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
        mkdir(name, mode)
    OSError

It looks like its' still pointing to the 2.7 version of python how Can I fix that? 看起来它仍然指向python的2.7版本,该如何解决呢?

使用virtualenv无需弄乱系统python或使用sudo运行pip。

您可以按照本教程中的说明进行操作,并使用python3创建virtualenv,然后将Django python解释器指向它。

尝试使用pip3代替pip。

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

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