Why Not Use System Python?
00:00
So, why not just use system Python? System Python is the Python that comes installed on your operating system. If you’re on a Mac or a Linux, then by default when you type python
in your terminal, you get a nice Python REPL, which uses system Python.
00:21 So, why not use it? One way to look at it is that this Python really belongs to the operating system. After all, it came installed with the operating system.
00:35
That’s even reflected when you run the which
command. Here, Python is available to all users, as evidenced by its location /usr/bin/python
.
00:47 Chances are, this isn’t a version of Python you want either. Python 2.7.16 is the system Python at this moment, which is no longer supported and should not be used for Python development as of January 1st, 2020.
01:06
To install a package into your system Python, you have to run sudo pip install
, which I won’t run because I don’t want to pollute my system.
01:16 And even if you wanted to, macOS won’t allow it. That’s because you’re installing the Python package globally, which is a real problem if another user comes along and wants to install a slightly different version of the package.
01:34 Problems with multiple versions of the same package tend to creep up on you and bite you when you least expect it. One common way this problem presents itself is a popular and stable package suddenly misbehaving on your system.
01:50 After hours of troubleshooting and Googling, you may find that you’ve installed the wrong version of a dependency, which is ruining your day.
02:00
Even if your Python version is installed in /usr/local/bin/python3
, you’re still not safe. You will run into the same permission and flexibility problems described earlier. In addition, you don’t really have much control over what version of Python comes installed on your OS. If you want to use the latest features of Python and you’re on Ubuntu, for example, you might just be out of luck.
02:31 The default versions might be too old, which means you’ll just have to wait for a new version of your OS to come out. Finally, some operating systems actually use the system Python for operation.
02:44
Take yum
, for example, which makes heavy use of Python to do its job. If you install a new version of Python and aren’t careful to install it into your user space, you could seriously damage your ability to use your OS.
03:03 Now that you’ve learned why you should not use system Python, let’s move on to the next lesson, where you’re going to learn what a package manager can do for you.
Become a Member to join the conversation.