欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Macbook安裝Python最新版本、GUI開發(fā)環(huán)境、圖像處理、視頻處理環(huán)境詳解

 更新時間:2020年02月17日 16:56:10   作者:Leemboy  
這篇文章主要介紹了Macbook安裝Python最新版本(3.6.4)、GUI開發(fā)環(huán)境、圖像處理、視頻處理環(huán)境詳解,需要的朋友可以參考下

1、安裝

有兩種安裝方法:

方法一:從Mac自帶的python安裝,命令如下:

$brewinstall python

如果出錯的話前面加上sudo

方法一安裝的是python2.7

方法二:從官網(wǎng)下載安裝最新版本(本次安裝的內(nèi)容)

官網(wǎng)地址:https://www.python.org/download,下載安裝最新版的python ,安裝簡單,一路點擊OK;不便之處是后續(xù)卸載維護(hù)需要手動進(jìn)行。

可以用這個命令查看python3安裝的位置:

$which python3

安裝完成后在終端中鍵入python3來驗證安裝是否成功.

打開Mac終端,輸入“python3”,回車,查看是否是自己裝的Python版本(如果Mac系統(tǒng)版本是10.8—10.11,默認(rèn)自帶的是Python2.7)。輸入Python3后,看到顯示【>>>】,說明已經(jīng)在Python的交互環(huán)境中了,可以正常使用。

這里安裝的是pip3。

安裝了python3之后,會有pip3

注意:

1. 使用pip install XXX 

新安裝的庫會放在這個目錄下面

python2.7/site-packages

2. 使用pip3 install XXX 

新安裝的庫會放在這個目錄下面

python3.6/site-packages

如果使用python3執(zhí)行程序,那么就不能import python2.7/site-packages中的庫

2、 安裝pip3

pip3 是一個安裝和管理 Python3 包的工具,pip 是一個安裝和管理 Python 包的工具,python安裝包的工具有easy_install, setuptools, pip,distribute等。distribute是setuptools的替代品,是對標(biāo)準(zhǔn)庫disutils模塊的增強(qiáng),我們知道disutils主要是用來更加容易的打包和分發(fā)包,特別是對其他的包有依賴的包。distribute被創(chuàng)建是因為Setuptools包不再維護(hù)了。而pip/pip3是easy_install的替代品。

2.1 先獲取pip安裝腳本:

$wget https://bootstrap.pypa.io/get-pip.py

如果沒有安裝wget可以去這里:https://ftp.gnu.org/gnu/wget/下載

  1. 用解壓工具解壓 :wget-1.9.1.tar.gz
  2. cd 進(jìn)入到解壓的目錄
  3. 命令行輸入:brew install wget 

可以輸入wget www.baidu.com  測試是否安裝成功

將所有內(nèi)容復(fù)制下來,新建get-pip.py文件,將內(nèi)容拷貝粘貼進(jìn)去.

2.2.安裝pip3

執(zhí)行命令行:

$ sudo python3 get-pip.py

執(zhí)行出錯:

The directory '/Users/xsnai/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.

換成下列命令:

$sudo -H python3 get-pip.py

Requirement already up-to-date: pip in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages

執(zhí)行成功!

終端命令行輸入pip3檢測。

檢測結(jié)果:

Usage:   

  pip <command> [options]

Commands:

  install                     Install packages.

  download                    Download packages.

  uninstall                   Uninstall packages.

  freeze                      Output installed packages in requirements format.

  list                        List installed packages.

  show                        Show information about installed packages.

  check                       Verify installed packages have compatible dependencies.

  search                      Search PyPI for packages.

  wheel                       Build wheels from your requirements.

  hash                        Compute hashes of package archives.

  completion                  A helper command used for command completion.

  help                        Show help for commands.



General Options:

  -h, --help                  Show help.

  --isolated                  Run pip in an isolated mode, ignoring

                              environment variables and user configuration.

  -v, --verbose               Give more output. Option is additive, and can be

                              used up to 3 times.

  -V, --version               Show version and exit.

  -q, --quiet                 Give less output. Option is additive, and can be

                              used up to 3 times (corresponding to WARNING,

                              ERROR, and CRITICAL logging levels).

  --log <path>                Path to a verbose appending log.

  --proxy <proxy>             Specify a proxy in the form

                              [user:passwd@]proxy.server:port.

  --retries <retries>         Maximum number of retries each connection should

                              attempt (default 5 times).

  --timeout <sec>             Set the socket timeout (default 15 seconds).

  --exists-action <action>    Default action when a path already exists:

                              (s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.

  --trusted-host <hostname>   Mark this host as trusted, even though it does

                              not have valid or any HTTPS.

  --cert <path>               Path to alternate CA bundle.

  --client-cert <path>        Path to SSL client certificate, a single file

                              containing the private key and the certificate

                              in PEM format.

  --cache-dir <dir>           Store the cache data in <dir>.

  --no-cache-dir              Disable the cache.

  --disable-pip-version-check

                              Don't periodically check PyPI to determine

                              whether a new version of pip is available for

                              download. Implied with --no-index.

2.3.修改pip3源

國內(nèi)由于網(wǎng)絡(luò)原因,使用pip3或和pip安裝一些模塊會特別慢甚至無法下載,因此我們需要修改源到國內(nèi)的一些鏡像地址,特別感謝國內(nèi)無私奉獻(xiàn)的組織~

首先進(jìn)入HOME路徑:

cd ~

創(chuàng)建.pip目錄:

mkdir .pip

創(chuàng)建pip.conf文件:

touch pip.conf

大家可以用自己喜歡的編輯器打開pip.conf文件,我現(xiàn)在使用的時v2ex的源,所以添加:

[global]

index-url = http://pypi.v2ex.com/simple

大家可以把index-url的值設(shè)置為自己實際源的地址.

至此pip3源修改成功,以后使用pip安裝模塊時都會從這個源去下載安裝,大家可以自行測試一下.

pip/pip3源使用國內(nèi)鏡像,加快下載速度和安裝成功率

國內(nèi)有如下下載源:

清華:https://pypi.tuna.tsinghua.edu.cn/simple

阿里云:http://mirrors.aliyun.com/pypi/simple/

中國科技大學(xué) https://pypi.mirrors.ustc.edu.cn/simple/

華中理工大學(xué):http://pypi.hustunique.com/

山東理工大學(xué):http://pypi.sdutlinux.org/ 

豆瓣:http://pypi.douban.com/simple/

臨時使用:

可以在使用pip/pip3的時候加參數(shù)-i https://pypi.tuna.tsinghua.edu.cn/simple

如:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider

這樣就會從清華這邊的鏡像去安裝pyspider庫。

永久修改,一勞永逸:

Linux下,修改 ~/.pip/pip.conf (沒有的話就創(chuàng)建一個文件夾及文件。文件夾要加“.”,表示是隱藏文件夾)

內(nèi)容如下:

[global]

index-url = https://pypi.tuna.tsinghua.edu.cn/simple

[install]

trusted-host=mirrors.aliyun.com

windows下,直接在user目錄中創(chuàng)建一個pip目錄,如:C:\Users\xx\pip,新建文件pip.ini。內(nèi)容同上。

3、python3圖片處理

PIL(Python Imaging Library)圖像處理模塊,在python3.X已經(jīng)替換為pillow模塊(文檔:http://pillow.readthedocs.org/en/latest/)。

直接使用pip3 install pillow即可安裝模塊,導(dǎo)入時使用from PIL import Image. 

命令行如下:

$pip3 install pillow

執(zhí)行過程如下:

Collecting pillow

 Downloading Pillow-4.3.0-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (3.5MB)

  100% |████████████████████████████████| 3.6MB 19kB/s 

Collecting olefile (from pillow)

 Downloading olefile-0.44.zip (74kB)

  100% |████████████████████████████████| 81kB 13kB/s 

Building wheels for collected packages: olefile

 Running setup.py bdist_wheel for olefile ... done

 Stored in directory: /Users/xsnai/Library/Caches/pip/wheels/20/58/49/cc7bd00345397059149a10b0259ef38b867935ea2ecff99a9b

Successfully built olefile

Installing collected packages: olefile, pillow

Successfully installed olefile-0.44 pillow-4.3.0

4、圖像中文字識別

4句代碼實現(xiàn)漢字識別

from PIL import Image
import pytesseract
text=pytesseract.image_to_string(Image.open('denggao.jpeg'),lang='chi_sim')
print(text)

需要先安裝兩個包,如果沒有安裝的話。

pip3 install PIL 
pip3 install pytesseract 

還需要下載中文語言包tesseract-ocr

更多關(guān)于Mabook安裝Python最新版本(3.6.4)、GUI開發(fā)環(huán)境、圖像處理、視頻處理環(huán)境請查看下面的相關(guān)鏈接

相關(guān)文章

  • 使用Python可設(shè)置抽獎?wù)邫?quán)重的抽獎腳本代碼

    使用Python可設(shè)置抽獎?wù)邫?quán)重的抽獎腳本代碼

    這篇文章主要介紹了Python可設(shè)置抽獎?wù)邫?quán)重的抽獎腳本,抽獎系統(tǒng)包含可給不同抽獎?wù)咴O(shè)置不同的權(quán)重,先從價值高的獎品開始抽,已經(jīng)中獎的人,不再參與后續(xù)的抽獎,本文通過實例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下
    2022-11-11
  • Python實現(xiàn)byte轉(zhuǎn)integer

    Python實現(xiàn)byte轉(zhuǎn)integer

    這篇文章主要介紹了Python實現(xiàn)byte轉(zhuǎn)integer操作,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2021-06-06
  • python控制臺顯示時鐘的示例

    python控制臺顯示時鐘的示例

    這篇文章主要介紹了python控制臺顯示時鐘的示例,需要的朋友可以參考下
    2014-02-02
  • Python使用win32com.client的方法示例

    Python使用win32com.client的方法示例

    本文主要介紹了Python使用win32com.client的方法示例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-02-02
  • Python中bytes和str的區(qū)別與聯(lián)系詳解

    Python中bytes和str的區(qū)別與聯(lián)系詳解

    Python3最重要的新特性之一是對字符串和二進(jìn)制數(shù)據(jù)流做了明確的區(qū),下面這篇文章主要給大家介紹了關(guān)于Python中bytes和str區(qū)別與聯(lián)系的相關(guān)資料,需要的朋友可以參考下
    2022-05-05
  • python?matplotlib繪畫十一種常見數(shù)據(jù)分析圖

    python?matplotlib繪畫十一種常見數(shù)據(jù)分析圖

    這篇文章主要介紹了python?matplotlib繪畫十一種常見數(shù)據(jù)分析圖,文章主要繪制折線圖、散點圖、直方圖、餅圖等需要的小伙伴可以參考一下文章具體內(nèi)容
    2022-06-06
  • 通過Python掃描代碼關(guān)鍵字并進(jìn)行預(yù)警的實現(xiàn)方法

    通過Python掃描代碼關(guān)鍵字并進(jìn)行預(yù)警的實現(xiàn)方法

    這篇文章主要介紹了通過Python掃描代碼關(guān)鍵字并進(jìn)行預(yù)警的實現(xiàn)方法,本文通過實例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-05-05
  • pyenv虛擬環(huán)境管理python多版本和軟件庫的方法

    pyenv虛擬環(huán)境管理python多版本和軟件庫的方法

    這篇文章主要介紹了pyenv虛擬環(huán)境管理python多版本和軟件庫,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-12-12
  • Pandas如何提取單元格中的文字并進(jìn)行切片處理

    Pandas如何提取單元格中的文字并進(jìn)行切片處理

    這篇文章主要介紹了Pandas如何提取單元格中的文字并進(jìn)行切片處理方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-02-02
  • Python程序設(shè)計入門(5)類的使用簡介

    Python程序設(shè)計入門(5)類的使用簡介

    這篇文章主要介紹了Python類的使用,需要的朋友可以參考下
    2014-06-06

最新評論