MAC下python3安裝django

在mac中同時存在python2.4和3.7的時候,安裝django撤师,使用pip安裝
  • 直接升級
pip install django

Collecting django
Downloading https://files.pythonhosted.org/packages/bf/e0/e659df5b5b82299fffd8b3df2910c99351b9308b8f45f5702cc4cdf946e9/Django-1.11.14-py2.py3-none-any.whl (7.0MB)
100% |████████████████████████████████| 7.0MB 89kB/s
Requirement already satisfied: pytz in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from django)
Installing collected packages: django
Exception: Traceback (most recent call last): File "/Library/Python/2.7/site-packages/pip-9.0.3-py2.7.egg/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/Library/Python/2.7/site-packages/pip-9.0.3-py2.7.egg/pip/commands/install.py", line 342, in run prefix=options.prefix_path, File "/Library/Python/2.7/site-packages/pip-9.0.3-py2.7.egg/pip/req/req_set.py", line 784, in install **kwargs File "/Library/Python/2.7/site-packages/pip-9.0.3-py2.7.egg/pip/req/req_install.py", line 851, in install self.move_wheel_files(self.source_dir, root=root, prefix=prefix) File "/Library/Python/2.7/site-packages/pip-9.0.3-py2.7.egg/pip/req/req_install.py", line 1064, in move_wheel_files isolated=self.isolated, File "/Library/Python/2.7/site-packages/pip-9.0.3-py2.7.egg/pip/wheel.py", line 377, in move_wheel_files clobber(source, dest, False, fixer=fixer, filter=filter) File "/Library/Python/2.7/site-packages/pip-9.0.3-py2.7.egg/pip/wheel.py", line 323, in clobber shutil.copyfile(srcfile, destfile) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 83, in copyfile with open(dst, 'wb') as fdst: IOError: [Errno 13] Permission denied: '/usr/local/bin/django-admin.py'
You are using pip version 9.0.3, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

  • 拋出異常,按照提示升級pip
pip install --upgrade pip

Collecting pip
Downloading https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 96kB/s
Installing collected packages: pip
Found existing installation: pip 9.0.3
Uninstalling pip-9.0.3:
Exception: Traceback (most recent call last): File "/Library/Python/2.7/site-packages/pip-9.0.3-py2.7.egg/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/Library/Python/2.7/site-packages/pip-9.0.3-py2.7.egg/pip/commands/install.py", line 342, in run prefix=options.prefix_path, File "/Library/Python/2.7/site-packages/pip-9.0.3-py2.7.egg/pip/req/req_set.py", line 778, in install requirement.uninstall(auto_confirm=True) File "/Library/Python/2.7/site-packages/pip-9.0.3-py2.7.egg/pip/req/req_install.py", line 754, in uninstall paths_to_remove.remove(auto_confirm) File "/Library/Python/2.7/site-packages/pip-9.0.3-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove renames(path, new_path) File "/Library/Python/2.7/site-packages/pip-9.0.3-py2.7.egg/pip/utils/__init__.py", line 267, in renames shutil.move(old, new) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 300, in move rmtree(src) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 247, in rmtree rmtree(fullname, ignore_errors, onerror) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 252, in rmtree onerror(os.remove, fullname, sys.exc_info()) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 250, in rmtree os.remove(fullname) OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip-9.0.3-py2.7.egg/EGG-INFO/dependency_links.txt'
You are using pip version 9.0.3, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

  • 依然報錯,使用sudo解決
sudo pip install --upgrade pip

Password:
The directory '/Users/ypn-mac-02/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/ypn-mac-02/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pip
Downloading https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 420kB/s
Installing collected packages: pip
Found existing installation: pip 9.0.3
Uninstalling pip-9.0.3:
Successfully uninstalled pip-9.0.3
Successfully installed pip-10.0.1

  • 安裝django
pip install django

Requirement already satisfied: django in /Library/Python/2.7/site-packages (1.11.14)
Requirement already satisfied: pytz in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from django) (2013.7)
matplotlib 1.3.1 requires nose, which is not installed. matplotlib 1.3.1 requires tornado, which is not installed.

  • 發(fā)現(xiàn)安裝到了python2.7中

  • 先查看pip的版本

pip -V

pip 10.0.1 from /Library/Python/2.7/site-packages/pip (python 2.7)

  • 查找資料贞谓,發(fā)現(xiàn)python3自帶pip十性,無需另外安裝

https://www.cnblogs.com/zhengyihan1216/p/6011640.html

  • 嘗試查看pip3版本叛溢,發(fā)現(xiàn)存在pip3
pip3 -V

pip 10.0.1 from /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip (python 3.7)
附注:在以下目錄中可以看見各種pip的版本

/usr/local/bin 
image.png
  • 用pip3安裝django
pip3 install django

Collecting django
Downloading https://files.pythonhosted.org/packages/ab/15/cfde97943f0db45e4f999c60b696fbb4df59e82bbccc686770f4e44c9094/Django-2.0.7-py3-none-any.whl (7.1MB)
100% |████████████████████████████████| 7.1MB 1.7MB/s
Collecting pytz (from django)
Downloading https://files.pythonhosted.org/packages/30/4e/27c34b62430286c6d59177a0842ed90dc789ce5d1ed740887653b898779a/pytz-2018.5-py2.py3-none-any.whl (510kB)
100% |████████████████████████████████| 512kB 6.8MB/s
Installing collected packages: pytz, django
Successfully installed django-2.0.7 pytz-2018.5

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市劲适,隨后出現(xiàn)的幾起案子楷掉,更是在濱河造成了極大的恐慌,老刑警劉巖霞势,帶你破解...
    沈念sama閱讀 207,248評論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件烹植,死亡現(xiàn)場離奇詭異,居然都是意外死亡愕贡,警方通過查閱死者的電腦和手機草雕,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,681評論 2 381
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來固以,“玉大人墩虹,你說我怎么就攤上這事∽旆模” “怎么了败晴?”我有些...
    開封第一講書人閱讀 153,443評論 0 344
  • 文/不壞的土叔 我叫張陵,是天一觀的道長栽渴。 經(jīng)常有香客問我尖坤,道長,這世上最難降的妖魔是什么闲擦? 我笑而不...
    開封第一講書人閱讀 55,475評論 1 279
  • 正文 為了忘掉前任慢味,我火速辦了婚禮场梆,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘纯路。我一直安慰自己或油,他們只是感情好,可當(dāng)我...
    茶點故事閱讀 64,458評論 5 374
  • 文/花漫 我一把揭開白布驰唬。 她就那樣靜靜地躺著顶岸,像睡著了一般。 火紅的嫁衣襯著肌膚如雪叫编。 梳的紋絲不亂的頭發(fā)上辖佣,一...
    開封第一講書人閱讀 49,185評論 1 284
  • 那天,我揣著相機與錄音搓逾,去河邊找鬼卷谈。 笑死,一個胖子當(dāng)著我的面吹牛霞篡,可吹牛的內(nèi)容都是我干的世蔗。 我是一名探鬼主播,決...
    沈念sama閱讀 38,451評論 3 401
  • 文/蒼蘭香墨 我猛地睜開眼朗兵,長吁一口氣:“原來是場噩夢啊……” “哼污淋!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起矛市,我...
    開封第一講書人閱讀 37,112評論 0 261
  • 序言:老撾萬榮一對情侶失蹤芙沥,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后浊吏,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體而昨,經(jīng)...
    沈念sama閱讀 43,609評論 1 300
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 36,083評論 2 325
  • 正文 我和宋清朗相戀三年找田,在試婚紗的時候發(fā)現(xiàn)自己被綠了歌憨。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 38,163評論 1 334
  • 序言:一個原本活蹦亂跳的男人離奇死亡墩衙,死狀恐怖务嫡,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情漆改,我是刑警寧澤心铃,帶...
    沈念sama閱讀 33,803評論 4 323
  • 正文 年R本政府宣布,位于F島的核電站挫剑,受9級特大地震影響去扣,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜樊破,卻給世界環(huán)境...
    茶點故事閱讀 39,357評論 3 307
  • 文/蒙蒙 一愉棱、第九天 我趴在偏房一處隱蔽的房頂上張望唆铐。 院中可真熱鬧,春花似錦奔滑、人聲如沸艾岂。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,357評論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽王浴。三九已至,卻和暖如春令宿,著一層夾襖步出監(jiān)牢的瞬間叼耙,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 31,590評論 1 261
  • 我被黑心中介騙來泰國打工粒没, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人簇爆。 一個月前我還...
    沈念sama閱讀 45,636評論 2 355
  • 正文 我出身青樓癞松,卻偏偏與公主長得像,于是被迫代替她去往敵國和親入蛆。 傳聞我的和親對象是個殘疾皇子响蓉,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 42,925評論 2 344

推薦閱讀更多精彩內(nèi)容