0

Is it possible to upgrade a package installed with apt-get, so located in /usr/lib/ , if such package do have a more recent version in pypi but not within the standard Ubuntu repositories as seen by apt?

I guess it is dangerous as it may break dependencies, but it's just to know.

swiss_knight
  • 5,787
  • 8
  • 50
  • 92

1 Answers1

0

Yes, it is.

I uninstall Flask

$ sudo apt-get remove python-flask

I don't have it:

$  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

I install it

$ 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'

Double-check:

$ 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]

Upgrading:

$ 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'

I see I have an issue with pip check, however:

$ 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]

So I must have some links or something broken, but this issue is still alive even if I use apt-get remove. All in all I am able to import newer version of Flask which is what you need I guess.

EDIT

OK, the issue is that pip installs Flask in different location then apt-get. This is pip output:

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

And this is apt-get's:

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

Here is a description of how to make pip install you package in a different directory. I have not tested it, however.

gonczor
  • 3,994
  • 1
  • 21
  • 46