Mac os下Python3安裝Django

來源:互聯網
上載者:User

標籤:alt   issue   www   user   base   www.   import   最新   test   

1.查看pip版本 沒有的話就是沒安裝成功 安裝python的時候一般會自動安裝pip

 

//pip版本 pip -V //對應python2.7pip 9.0.1 from /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)pip3 -V //對應python3.6pip 9.0.1 from /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (python 3.6)

 

2.用pip3/Python3安裝Django,1.11.7是最新穩定版(官網download頁面有 https://www.djangoproject.com/download )
這裡注意用sudo 不然會報錯
sudo pip3 install Django==1.11.7

 

提示 :

Installing collected packages: DjangoFound existing installation: Django 2.1.dev20171130142844 //之前用github下載安裝的最新版,2.x 版本太高Uninstalling Django-2.1.dev20171130142844:Successfully uninstalled Django-2.1.dev20171130142844 //自動卸載掉之前的版本Successfully installed Django-1.11.7 //安裝成功

 

 

3.測試是否安裝成功
cd /Users/z/PyP/Django

 

4.建立一個服務
sudo django-admin.py startproject testLocalHostcd testLocalHost

 

5.運行服務,因為是用pip3/python3安裝的Django 所以應該用python3來運行
python3 manage.py runserver

 

讓命令列飛一會~

...xxx.....xxxdjango.db.utils.OperationalError: unable to open database file

 

報錯了。

 

6.然後用管理員權限運行:
sudo python3 manage.py runserver

 


列印:

Performing system checks...System check identified no issues (0 silenced).You have 13 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.December 01, 2017 - 08:33:50Django version 1.11.7, using settings ‘testLocalHost.settings‘Starting development server at http://127.0.0.1:8000/Quit the server with CONTROL-C.

 

成功,瀏覽器輸入http://127.0.0.1:8000/可以看到

 


查看Django版本

import djangoprint(django.VERSION)

 

列印:(1, 11, 7, ‘final‘, 0) 說明是1.11.7版本。

查看python3安裝目錄

import sysprint(sys.path)

 

列印xxxxxx /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6 xxxx 即是python3安裝目錄

pip3 安裝目錄:/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip

pip 安裝目錄在預設python目錄下

Django安裝目錄(用pip3安裝) :/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django

 

Mac os下Python3安裝Django

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.