Python 用git安装django时出现错误?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42196124/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 21:22:18  来源:igfitidea点击:

There are errors when I install django by git?

pythondjango

提问by yensheng

I install django through :

我通过以下方式安装 django:

git clone git://github.com/django/django.git

pip install -e django/

git 克隆 git://github.com/django/django.git

pip install -e django/

I use Ubuntu 16.04.

我使用 Ubuntu 16.04。

But some errors occur :

但是会出现一些错误:

Obtaining file:///home/leo/django
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/home/leo/django/setup.py", line 32, in <module>
        version = __import__('django').get_version()
      File "django/__init__.py", line 1, in <module>
        from django.utils.version import get_version
      File "django/utils/version.py", line 60, in <module>
        @functools.lru_cache()
    AttributeError: 'module' object has no attribute 'lru_cache'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /home/leo/django/

How to fix this ? Thank you.

如何解决这个问题?谢谢你。

回答by george

The last Django version does not support python 2.7.

最后一个 Django 版本不支持 python 2.7。

If you really want to use python 2.7 and also use Django you should install a previous Django version.

如果您真的想使用 python 2.7 并同时使用 Django,您应该安装以前的 Django 版本。

The latest supported is: 1.11

最新支持的是:1.11

Therefore, just run:

因此,只需运行:

pip install django==1.11

回答by vimal1083

This because django version you have needs python3interpreter. so try to run the same command using pip3

这是因为您拥有的 Django 版本需要python3解释器。所以尝试使用运行相同的命令pip3

To install pip3sudo apt-get -y install python3-pip

安装 pip3sudo apt-get -y install python3-pip

then run

然后运行

pip3 install -e django/

pip3 install -e django/

回答by Jon

You can install a Python 2 version of Django using git - you just need to checkout the correct release tag first. Try something like

您可以使用 git 安装 Python 2 版本的 Django - 您只需要先签出正确的发布标签。尝试类似的东西

git clone git://github.com/django/django.git
cd django
git checkout 1.11.0
cd ..
pip install -e django/

That said, you are much better off using pip directly, as other solutions suggest.

也就是说,正如其他解决方案所建议的那样,直接使用 pip 会好得多。

回答by Dking

Right > c:\Python27\Scripts>pip install django==1.11
Wrong > c:\Python27\Scripts>pip2.7 install django

c:\Python27\Scripts>pip2.7 install django
Collecting django
  Using cached Django-2.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "c:\users\shyv\appdata\local\temp\pip-build-idpp6j\django\setup.py", line 32, in <module>
        version = __import__('django').get_version()
      File "django\__init__.py", line 1, in <module>
        from django.utils.version import get_version
      File "django\utils\version.py", line 61, in <module>
        @functools.lru_cache()
    AttributeError: 'module' object has no attribute 'lru_cache'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\shyv\appdata\local\temp\pip-build-idpp6j\django\

c:\Python27\Scripts>pip install django==1.11
Collecting django==1.11
c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cau
  SNIMissingWarning
c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL co
  InsecurePlatformWarning
  Downloading Django-1.11-py2.py3-none-any.whl (6.9MB)
    100% |################################| 6.9MB 108kB/s
Collecting pytz (from django==1.11)
  Downloading pytz-2017.3-py2.py3-none-any.whl (511kB)
    100% |################################| 512kB 922kB/s
Installing collected packages: pytz, django
Successfully installed django-1.11 pytz-2017.3