Mac上安裝python3 和pip3

首先我不是用brew安裝python3的,是用下載的python3.7.2的源碼然後自己編譯的。

一開始我用brew安裝的python3,pip總是報錯“ImportError: cannot import name HTTPSHandle”反正就是ssl方面的問題。網上找了一圈,說是ssl要先安裝,然後重新編譯python。

 

我去官網下載的源碼:https://www.python.org/downloads/source/

下載的tar.xz文件,然後自己解壓。

 

要先用brew安裝openssl和openssl-devel

命令: brew install openssl

            brew install openssl-devel

 

然後

進入到解壓的python的目錄下
./configure --enable-shared --enable-loadable-sqlite-extensions

sudo make
sudo make install

 

-bash-3.2$ pip3 -V
pip 18.1 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
-bash-3.2$ python3
Python 3.7.2 (default, Jan 25 2019, 10:03:23) 
[Clang 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymysql
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pymysql'
>>> exit()
-bash-3.2$ pip3 install pymysql
Collecting pymysql
  Downloading https://files.pythonhosted.org/packages/ed/39/15045ae46f2a123019aa968dfcba0396c161c20f855f11dea6796bcaae95/PyMySQL-0.9.3-py2.py3-none-any.whl (47kB)
    100% |████████████████████████████████| 51kB 14kB/s 
Installing collected packages: pymysql
Successfully installed pymysql-0.9.3
-bash-3.2$ python3
Python 3.7.2 (default, Jan 25 2019, 10:03:23) 
[Clang 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymysql
>>> from xlwt import Workbook
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'xlwt'
>>> exit()
-bash-3.2$ pip3 install xlwt
Collecting xlwt
  Downloading https://files.pythonhosted.org/packages/44/48/def306413b25c3d01753603b1a222a011b8621aed27cd7f89cbc27e6b0f4/xlwt-1.3.0-py2.py3-none-any.whl (99kB)
    100% |████████████████████████████████| 102kB 96kB/s 
Installing collected packages: xlwt
Successfully installed xlwt-1.3.0
-bash-3.2$ python3
Python 3.7.2 (default, Jan 25 2019, 10:03:23) 
[Clang 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from xlwt import Workbook
>>> exit
Use exit() or Ctrl-D (i.e. EOF) to exit
>>> exit()
-bash-3.2$ 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章