简体   繁体   中英

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

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 )

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.

1) You should not modify the system's binaries yourself directly

2) If your $PATH variable doesn't contain /usr/local/bin , the naming of that secondary directory isn't really important. You can install / upgrade independently wherever you have installed your extra binaries.

3) For Python specifically, you could also just use conda / virtualenv invoked by your system's python to manage your versions & projects.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM