Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

/usr/bin/python vs /usr/local/bin/python

Tags:

python

linux

On Linux, specifically Debian Jessie, should I use /usr/bin/python or should I install another copy in /usr/local/bin?

I understand that the former is the system version and that it can change when the operating system is updated. This would mean that I can update the version in the latter independently of the OS. As I am already using python 3, I don't see what significant practical difference that would make.

Are there other reasons to use a local version?

(I know there are ~42 SO questions about how to change between version, but I can't find any about why)

like image 791
ericksonla Avatar asked Oct 18 '22 17:10

ericksonla


1 Answers

I don't think I'd recommend either of these approaches, and simply would stick to a virtualenv to further isolate Python instances.

The biggest reason that you'd use a specific Python environment - be it the system, a local one, or a virtualenv - would be control. The more control you have over the environment and what gets installed in it, the less surface area you have to find or encounter bugs due to libraries which you didn't realize you introduced. If it's a virtualenv, that also makes cleanup easier; just delete the virtualenv when you no longer need it as opposed to trying to uninstall libraries installed at the system level.

Not just that, but more and more distros are converting their scripts to use Python 3. The less stomping around you do in that environment, the better.

Finally - just as a generic Shell scripting tip - I'd also encourage the use of /usr/bin/env python to ensure that you're using the version of Python that's most prominent on your PATH.

like image 94
Makoto Avatar answered Oct 20 '22 10:10

Makoto