In this article, I will be installing the lovely python on FreeBSD system using FreeBSD Port Collection. The Port Collection is a PMS (Package Management System) for installing applications on FreeBSD. In the beginning, we want to obtain the Port Collection and make sure that it’s updated.
One of the easiest way to update the Port Collection is using portsnap command.
portsnap will connect to a remote site and download a snapshot of the Ports Collection into /var/db/portsnap.
#portsnap fetch
If this is the first time to use portsnap, you should extract the “compressed” snapshot into /user/ports. You can check this folder before if you are not sure about it.
#portsnap extract
InĀ case the snapshop is already populated, you need only to update it and no need for subsequent fetch:
#portsnap update
Tips: portsnap fetch, extract and update can run together (#portsnap fetch update).
Now, to install python we need to find the desired Python port. In our case, python port can be found in /usr/ports/lang/pythonX (where X is the python’s version).
# cd /usr/ports/lang/python26
#make install clean
At this stage, python26 should be installed and can be tested as the following:
#python -V
or
#pkg_info | grep -i python
Last thing I would like to shed some light on is the installation process of the port. The “make install clean” command makes the installation in three steps:
make: to compile the port code
make install: to install the port
make clean: to delete the compilation temporary directories
Happy pythoning!