Install software

If you don’t have any specific requirements for needed software, you can use pkg utility to install the pre-built package on FreeBSD, and it looks like using yum or apt-get on GNU/Linux boxes. E.g., install python on your host:

  1. # pkg install python
  2. ......
  3. ===========================================================================
  4. Note that some standard Python modules are provided as separate ports
  5. as they require additional dependencies. They are available as:
  6. bsddb databases/py-bsddb
  7. gdbm databases/py-gdbm
  8. sqlite3 databases/py-sqlite3
  9. tkinter x11-toolkits/py-tkinter
  10. ===========================================================================

Now you can run python now:

  1. # python
  2. Python 2.7.11 (default, Jun 5 2016, 01:23:11)
  3. [GCC 4.2.1 Compatible FreeBSD Clang 3.4.1 (tags/RELEASE_34/dot1-final 208032)] on freebsd10
  4. Type "help", "copyright", "credits" or "license" for more information.
  5. >>>

But the end logs of installing python prompts we still need to install other 4 packages: py-bsddb, py-gdbm, py-sqlite3 and py-tkinter, otherwise “import sqlite3“ will complain:

  1. >>> import sqlite3
  2. Traceback (most recent call last):
  3. File "<stdin>", line 1, in <module>
  4. File "/usr/local/lib/python2.7/sqlite3/__init__.py", line 24, in <module>
  5. from dbapi2 import *
  6. File "/usr/local/lib/python2.7/sqlite3/dbapi2.py", line 28, in <module>
  7. from _sqlite3 import *
  8. ImportError: No module named _sqlite3

This introduces another installation method: using ports. This method will download, compile and install from source code, and the benefit of this approach is you can do some customizations if you want. You can find all ports under /usr/ports directory. Now you begin to install py-bsddb (follow this method to set up py-gdbm, py-sqlite3 and py-tkinter):

  1. # cd /usr/ports/databases/py-bsddb
  2. # make install clean

After all are installed, we can use sqlite in python now:

  1. # python
  2. Python 2.7.11 (default, Jun 5 2016, 01:23:11)
  3. [GCC 4.2.1 Compatible FreeBSD Clang 3.4.1 (tags/RELEASE_34/dot1-final 208032)] on freebsd10
  4. Type "help", "copyright", "credits" or "license" for more information.
  5. >>> import sqlite3

The other method is installing from DVD:
(1) Put DVD in the drive;
(2) Mount DVD:

  1. mkdir -p /dist
  2. mount -t cd9660 /dev/cd0 /dist

(3) Install the package (E.g., xorg):

  1. env REPOS_DIR=/dist/packages/repos pkg install xorg

References:
Packages and Ports: Adding Software in FreeBSD;
Get started with FreeBSD: A brief intro for Linux users;
FreeBSD 10 install packages from DVD.