执行以下步骤后
# cd /usr/lib/python
python2.7/ python3/ python3.5/ python3.6/
# easy_install3 --version
setuptools 20.7.0 from /usr/lib/python3/dist-packages (Python 3.5)
# whoami
root
# echo $PYTHONPATH
/usr/lib/python3.6/site-packages
#
# easy_install3 --install-dir /usr/lib/python3.6/site-packages django==1.9
Creating /usr/lib/python3.6/site-packages/site.py
Searching for django==1.9
Reading https://pypi.python.org/simple/django/
Best match: Django 1.9
Downloading https://pypi.python.org/packages/c2/14/e282ae720c21b48316b66126d7295ace0790438b27482b7a3dd9a6e3c3e1/Django- 1.9.tar.gz#md5=110389cf89196334182295165852e082
Processing Django-1.9.tar.gz
Writing /tmp/easy_install-5672_wl4/Django-1.9/setup.cfg
Running Django-1.9/setup.py -q bdist_egg --dist-dir /tmp/easy_install-5672_wl4/Django-1.9/egg-dist-tmp-iuog46mc
no previously-included directories found matching 'django/contrib/admin/bin'
warning: no previously-included files matching '__pycache__' found under directory '*'
File "build/bdist.linux-x86_64/egg/django/conf/app_template/models.py", line 1
{{ unicode_literals }}from django.db import models
^
SyntaxError: invalid syntax
File "build/bdist.linux-x86_64/egg/django/conf/app_template/apps.py", line 4
class {{ camel_case_app_name }}Config(AppConfig):
^
SyntaxError: invalid syntax
creating /usr/lib/python3.6/site-packages/Django-1.9-py3.5.egg
Extracting Django-1.9-py3.5.egg to /usr/lib/python3.6/site-packages
File "/usr/lib/python3.6/site-packages/Django-1.9-py3.5.egg/django/conf/app_template/models.py", line 1
{{ unicode_literals }}from django.db import models
^
SyntaxError: invalid syntax
File "/usr/lib/python3.6/site-packages/Django-1.9-py3.5.egg/django/conf/app_template/apps.py", line 4
class {{ camel_case_app_name }}Config(AppConfig):
^
SyntaxError: invalid syntax
Adding Django 1.9 to easy-install.pth file
Installing django-admin.py script to /usr/lib/python3.6/site-packages
Installing django-admin script to /usr/lib/python3.6/site-packages
Installed /usr/lib/python3.6/site-packages/Django-1.9-py3.5.egg
Processing dependencies for django==1.9
Finished processing dependencies for django==1.9
#
我在安装过程中看到Django代码中的语法错误。
修改
修复easy_install问题后,我看到同样的错误,
$ sudo easy_install django==1.9
Searching for django==1.9
Reading https://pypi.python.org/simple/django/
Downloading https://pypi.python.org/packages/c2/14/e282ae720c21b48316b66126d7295ace0790438b27482b7a3dd9a6e3c3e1/Django-1.9.tar.gz#md5=110389cf89196334182295165852e082
Best match: Django 1.9
Processing Django-1.9.tar.gz
Writing /tmp/easy_install-oayz20ph/Django-1.9/setup.cfg
Running Django-1.9/setup.py -q bdist_egg --dist-dir /tmp/easy_install-oayz20ph/Django-1.9/egg-dist-tmp-nrnqftyo
no previously-included directories found matching 'django/contrib/admin/bin'
warning: no previously-included files matching '__pycache__' found under directory '*'
File "build/bdist.linux-x86_64/egg/django/conf/app_template/models.py", line 1
{{ unicode_literals }}from django.db import models
^
SyntaxError: invalid syntax
File "build/bdist.linux-x86_64/egg/django/conf/app_template/apps.py", line 4
class {{ camel_case_app_name }}Config(AppConfig):
^
SyntaxError: invalid syntax
creating /usr/local/lib/python3.6/dist-packages/Django-1.9-py3.6.egg
Extracting Django-1.9-py3.6.egg to /usr/local/lib/python3.6/dist-packages
File "/usr/local/lib/python3.6/dist-packages/Django-1.9-py3.6.egg/django/conf/app_template/models.py", line 1
{{ unicode_literals }}from django.db import models
^
SyntaxError: invalid syntax
File "/usr/local/lib/python3.6/dist-packages/Django-1.9-py3.6.egg/django/conf/app_template/apps.py", line 4
class {{ camel_case_app_name }}Config(AppConfig):
^
SyntaxError: invalid syntax
Adding Django 1.9 to easy-install.pth file
Installing django-admin.py script to /usr/local/bin
Installing django-admin script to /usr/local/bin
Installed /usr/local/lib/python3.6/dist-packages/Django-1.9-py3.6.egg
Processing dependencies for django==1.9
Finished processing dependencies for django==1.9
$
目前使用pip3方法并安装了django
问题:
这种语法错误会被忽略吗?
答案 0 :(得分:0)
使用apt-get在Ubuntu上安装pip
对于python3
sudo apt-get install python3-pip
然后安装django不会没问题
在python3中安装django
pip3 install django
如果你已经有py3.6那么
wget https://bootstrap.pypa.io/get-pip.py
sudo python3.6 get-pip.py
sudo ln -s /usr/bin/python3.6 /usr/local/bin/python3
sudo ln -s /usr/local/bin/pip /usr/local/bin/pip3
然后用py3.6安装Django
python3.6 -m pip install django