最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

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

1、安裝

有兩種安裝方法:

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

$brewinstall python

如果出錯(cuò)的話前面加上sudo

方法一安裝的是python2.7

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

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

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

$which python3

安裝完成后在終端中鍵入python3來(lái)驗(yàn)證安裝是否成功.

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

這里安裝的是pip3。

安裝了python3之后,會(huì)有pip3

注意:

1. 使用pip install XXX 

新安裝的庫(kù)會(huì)放在這個(gè)目錄下面

python2.7/site-packages

2. 使用pip3 install XXX 

新安裝的庫(kù)會(huì)放在這個(gè)目錄下面

python3.6/site-packages

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

2、 安裝pip3

pip3 是一個(gè)安裝和管理 Python3 包的工具,pip 是一個(gè)安裝和管理 Python 包的工具,python安裝包的工具有easy_install, setuptools, pip,distribute等。distribute是setuptools的替代品,是對(duì)標(biāo)準(zhǔn)庫(kù)disutils模塊的增強(qiáng),我們知道disutils主要是用來(lái)更加容易的打包和分發(fā)包,特別是對(duì)其他的包有依賴的包。distribute被創(chuàng)建是因?yàn)镾etuptools包不再維護(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  測(cè)試是否安裝成功

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

2.2.安裝pip3

執(zhí)行命令行:

$ sudo python3 get-pip.py

執(zhí)行出錯(cuò):

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檢測(cè)。

檢測(cè)結(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源

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

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

cd ~

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

mkdir .pip

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

touch pip.conf

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

[global]

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

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

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

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

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

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

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

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

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

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

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

臨時(shí)使用:

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

如:

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

這樣就會(huì)從清華這邊的鏡像去安裝pyspider庫(kù)。

永久修改,一勞永逸:

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

內(nèi)容如下:

[global]

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

[install]

trusted-host=mirrors.aliyun.com

windows下,直接在user目錄中創(chuàng)建一個(gè)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)入時(shí)使用from PIL import Image. 

命令行如下:

$pip3 install pillow

執(zhí)行過(guò)程如下:

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、圖像中文字識(shí)別

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

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

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

pip3 install PIL 
pip3 install pytesseract 

還需要下載中文語(yǔ)言包tesseract-ocr

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

相關(guān)文章

  • django 常用orm操作詳解

    django 常用orm操作詳解

    下面小編就為大家?guī)?lái)一篇django 常用orm操作詳解。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-09-09
  • Jupyter Notebook 實(shí)現(xiàn)正常顯示中文和負(fù)號(hào)

    Jupyter Notebook 實(shí)現(xiàn)正常顯示中文和負(fù)號(hào)

    這篇文章主要介紹了Jupyter Notebook 實(shí)現(xiàn)正常顯示中文和負(fù)號(hào),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-04-04
  • Python實(shí)現(xiàn)隱馬爾可夫模型的前向后向算法的示例代碼

    Python實(shí)現(xiàn)隱馬爾可夫模型的前向后向算法的示例代碼

    這篇文章主要介紹了Python實(shí)現(xiàn)隱馬爾可夫模型的前向后向算法,本文通過(guò)實(shí)例代碼給大家講解的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-12-12
  • Django logging配置及使用詳解

    Django logging配置及使用詳解

    這篇文章主要介紹了Django logging配置及使用詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-07-07
  • Python中實(shí)現(xiàn)插值法的示例詳解

    Python中實(shí)現(xiàn)插值法的示例詳解

    在數(shù)據(jù)處理和分析中,插值法是一種常用的數(shù)值分析技術(shù),用于估計(jì)在已知數(shù)據(jù)點(diǎn)之間的值,本文將詳細(xì)介紹Python中插值法的實(shí)現(xiàn)方法,需要的可以參考下
    2024-02-02
  • pytorch教程resnet.py的實(shí)現(xiàn)文件源碼分析

    pytorch教程resnet.py的實(shí)現(xiàn)文件源碼分析

    torchvision.models這個(gè)包中包含alexnet、densenet、inception、resnet、squeezenet、vgg等常用的網(wǎng)絡(luò)結(jié)構(gòu),并且提供了預(yù)訓(xùn)練模型,可以通過(guò)簡(jiǎn)單調(diào)用來(lái)讀取網(wǎng)絡(luò)結(jié)構(gòu)和預(yù)訓(xùn)練模型
    2021-09-09
  • python利用dir函數(shù)查看類中所有成員函數(shù)示例代碼

    python利用dir函數(shù)查看類中所有成員函數(shù)示例代碼

    這篇文章主要給大家介紹了關(guān)于python如何利用dir函數(shù)查看類中所有成員函數(shù)的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用python具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)下吧。
    2017-09-09
  • Python3 實(shí)現(xiàn)串口兩進(jìn)程同時(shí)讀寫

    Python3 實(shí)現(xiàn)串口兩進(jìn)程同時(shí)讀寫

    今天小編就為大家分享一篇Python3 實(shí)現(xiàn)串口兩進(jìn)程同時(shí)讀寫,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2019-06-06
  • 對(duì)python-3-print重定向輸出的幾種方法總結(jié)

    對(duì)python-3-print重定向輸出的幾種方法總結(jié)

    今天小編就為大家分享一篇對(duì)python-3-print重定向輸出的幾種方法總結(jié),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-05-05
  • python用函數(shù)創(chuàng)造字典的實(shí)例講解

    python用函數(shù)創(chuàng)造字典的實(shí)例講解

    在本篇文章里小編給大家整理的是一篇關(guān)于python用函數(shù)創(chuàng)造字典的實(shí)例講解內(nèi)容,有需要的朋友們可以學(xué)習(xí)參考下。
    2021-06-06

最新評(píng)論

黔南| 萨嘎县| 香格里拉县| 浙江省| 连云港市| 伊吾县| 新巴尔虎左旗| 顺昌县| 涪陵区| 涿州市| 集贤县| 高州市| 长治县| 古丈县| 铁岭县| 汝南县| 隆昌县| 临江市| 公主岭市| 湘潭县| 天峨县| 贞丰县| 毕节市| 镇巴县| 达拉特旗| 淳安县| 洛宁县| 自贡市| 两当县| 仙桃市| 襄樊市| 阆中市| 封开县| 罗江县| 日照市| 昭平县| 景德镇市| 青州市| 高淳县| 濉溪县| 克山县|