2017-05-26 62 views
0

是否有可能升级安装apt-get的软件包,因此位于/ usr/lib /中,如果这样的软件包在pypi中有更新的版本,但不在标准的Ubuntu软件仓库中,如apt看到的那样?在/ usr/lib中升级apt安装的Python软件包?

我想这是危险的,因为它可能会打破依赖关系,但它只是为了知道。

+1

向google索要'python virtualenv' – gboffi

+0

这样可以节省中断依赖的风险。 – gonczor

回答

0

是的。

卸载Flask

$ sudo apt-get remove python-flask 

我没有它:

$ python 
Python 2.7.13 (default, Jan 19 2017, 14:48:08) 
[GCC 6.3.0 20170118] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import flask 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
ImportError: No module named flask 

我安装

$ sudo apt-get install python-flask 
$ python 
Python 2.7.13 (default, Jan 19 2017, 14:48:08) 
[GCC 6.3.0 20170118] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import flask 
>>> flask.__version__ 
'0.12' 

仔细检查:

$ pip list -o | grep Flask 
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning. 
Flask (0.12.1) - Latest: 0.12.2 [wheel] 

升级:

$ sudo pip install --upgrade Flask 
... 
Successfully installed Flask-0.12.2 Jinja2-2.9.6 MarkupSafe-1.0 Werkzeug-0.12.2 click-6.7 itsdangerous-0.24 

$ python 
Python 2.7.13 (default, Jan 19 2017, 14:48:08) 
[GCC 6.3.0 20170118] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import flask 
>>> flask.__version__ 
'0.12.2' 

我看到我有点子检查的问题,但是:

$ pip list -o | grep Flask 
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning. 
Flask (0.12.1) - Latest: 0.12.2 [wheel] 

所以我必须有一些链接什么的坏了,但这个问题还活着,即使我使用apt-get remove。总之,我能够导入更新版本的Flask,这是你所需要的,我猜。

编辑

确定,问题是pip在不同的位置,然后apt-get安装Flask。这是PIP输出:

>>> flask.__file__ 
'/usr/local/lib/python2.7/dist-packages/flask/__init__.pyc' 

这是易于得到的:

>>> flask.__file__ 
'/usr/lib/python2.7/dist-packages/flask/__init__.pyc' 

Here是如何让pip安装你在不同的目录包装的说明。但是,我没有测试过它。