簡體   English   中英

升級 Python 模塊的最佳實踐

[英]Best practice for upgrading Python modules

我已經學習 Python 幾個月了,但現在我發現我的 2.7 安裝存在一些問題,因為我已經研究了諸如 nltk 之類的模塊。

但是,當我想使用幫助(“模塊”)列出模塊時,我認為可以解釋問題的主要錯誤是:

    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/distribute-0.6.28-py2.7.egg/setuptools/command/install_scripts.py:3: UserWarning: Module numpy was already imported from /Library/Python/2.7/site-packages/numpy-override/numpy/__init__.pyc, but /Library/Python/2.7/site-packages/numpy-1.8.0.dev_5c944b9_20120828-py2.7-macosx-10.8-x86_64.egg is being added to sys.path
from pkg_resources import Distribution, PathMetadata, ensure_directory

我還收到以下與棄用模塊有關的錯誤:

    /Library/Python/2.7/site-packages/statsmodels-0.5.0-py2.7-macosx-10.8-intel.egg/scikits/statsmodels/__init__.py:2: UserWarning: scikits.statsmodels namespace is deprecated and will be removed in 0.5, please use statsmodels instead

我仍在努力掌握路徑。 我將來如何避免這個問題?

您已經在操作系統 Python 庫下安裝了軟件包。 這是大不不。 您應該做的是使用 virtualenv 工具創建一個隔離的、一次性的 Python 環境:

http://opensourcehacker.com/2012/09/16/recommended-way-for-sudo-free-installation-of-python-software-with-virtualenv/

這樣,當您升級包或需要刪除它們時,您始終可以通過簡單地刪除環境並創建新環境來重置所有 Python 包的狀態。

通過pipeasy_install命令安裝的 Python 包很容易安裝,但無法卸載...

但是,當損壞已經發生時,您需要手動嘗試清理 /Library/Python/2.7/site-packages/ 通過刪除文件並盡量不要在此過程中破壞您的系統 Python。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM