溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

python模塊的安裝目錄在哪里

發(fā)布時(shí)間:2021-12-04 10:56:03 來(lái)源:億速云 閱讀:540 作者:小新 欄目:安全技術(shù)

這篇文章主要為大家展示了“python模塊的安裝目錄在哪里”,內(nèi)容簡(jiǎn)而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“python模塊的安裝目錄在哪里”這篇文章吧。

Python的強(qiáng)大,其中一個(gè)重要原因是Python有很豐富的庫(kù)(模塊)從而可以比較方便地處理各種各樣的問(wèn)題。Python開發(fā)的第三方modules一般都安裝在一些固定的路徑,如下:

Unix(Linux): prefix/lib/pythonX.Y/site-packages 默認(rèn)路徑:/usr/local/lib/pythonX.Y/site-packages

Windows: prefix\Lib\site-packages 默認(rèn)路徑:C:\PythonXY\Lib\site-packages

另外,在Unix-like系統(tǒng)上,Python自身build-in的模塊一般位于:/usr/lib/pythonX.Y/site-packages

從源代碼安裝模塊的命令一般為:setup.py install

當(dāng)然,可以根據(jù)需要改變默認(rèn)的第三方模塊安裝路徑,在命令中可以加上參數(shù):–user, or –home, or –prefix and –exec-prefix, or –install-base and –install-platbase 等來(lái)指定安裝路徑。

需要注意的是:模塊的安裝路徑一定要在 sys.path 這個(gè)List中,才能在腳本中可以正常地 import 進(jìn)來(lái)。

關(guān)于模塊的裝, Python官方參考文檔是:http://docs.python.org/3.3/install/index.html#how-installation-works

另外,在Debian系列(包括Ubuntu)的Linux上,一般采用 dist-packages 而不是采用 site-packages 目錄;Debian項(xiàng)目的網(wǎng)站上,也對(duì)此作了說(shuō)明,詳見:http://wiki.debian.org/Python#Deviations_from_upstream

下面是我的系統(tǒng)上看到的Python模塊的一些路徑:

# 在一臺(tái)RHEL6.3 x86-64系統(tǒng)上

[root@jay-linux ~]# cat /etc/issue

Red Hat Enterprise Linux Server release 6.3 (Santiago)

Kernel \r on an \m

[root@jay-linux ~]# ls /usr/lib/python2.6/site-packages/

[root@jay-linux ~]# ls /usr/lib64/python2.6/site-packages/

[root@jay-linux ~]# ls /usr/local/lib64/python2.6/site-packages/

# 切換到一臺(tái)Ubuntu x86-64系統(tǒng)上

master@jay-intel:~$ cat /etc/issue

Ubuntu 12.04.1 LTS \n \l

master@jay-intel:~$ ls /usr/lib/python2.7/dist-packages/

master@jay-intel:~$ ls /usr/local/lib/python2.7/dist-packages/

easy-installNaNh mysql_connector_repackaged-0.3.1-py2.7.egg

master@jay-intel:~$ python3

Python 3.2.3 (default, Oct 19 2012, 20:10:41)

[gcc 4.6.3] on linux2

type "help", "copyright", "credits" or "license" for more information.

>>> import sys

>>> sys.path

[‘‘, ‘/usr/local/lib/python3.2/dist-packages/mysql_connector_repackaged-0.3.1-py3.2.egg‘, ‘/usr/lib/python3.2‘, ‘/usr/lib/python3.2/plat-linux2‘, ‘/usr/lib/python3.2/lib-dynload‘, ‘/usr/local/lib/python3.2/dist-packages‘, ‘/usr/lib/python3/dist-packages‘]

>>>

以上是“python模塊的安裝目錄在哪里”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI