I'm facing a confusing situation. The official latest fully-supported version of Python is 3.9, and while it's available in FreeBSD pkg, pip-3.9 isn't, and I'll be needing it in the future when Python 3.7 reaches EOL.

In short:

  • Python 3.7: available,
  • Python 3.9: available,
  • pip 3.7: availabe,
  • pip 3.9: not available.

I skimmed through FreeBSD handbook and relevant FreeBSD wiki pages, but there doesn't seem to be an explanation. So what's happening here?

2 Answers 2


The set of binary packages distributed by the FreeBSD Project, which you can install with pkg(8), includes Python packages for only one Python version at a time (which is Python 3.7 at the moment as you can see in the Mk/bsd.default-versions.mk file in the FreeBSD Ports tree). That's why you only see the Python 3.7 flavor of pip available in the package repository (i.e., py37-pip).

Users, who desire to use a different Python version for their FreeBSD packages, can build the packages from source. The default version of Python can be set in make.conf(5) as follows:

DEFAULT_VERSIONS=python=3.9 python3=3.9

If you decide to follow this path, I recommend using poudriere to set up your own package repository. This is the official FreeBSD tool for building packages. Also, it's worth noting that building from source is generally well supported in FreeBSD.

If adding poudriere to your infrastructure is too high of a cost, then I'd just create a virtual environment for Python and then install the desired pip version there.

I advise against running pip install --upgrade pip as root since it is going to pollute your system. The reason is that you are going to upgrade pip you installed with pkg with pip. This may lead to unexpected inconsistencies on your system.


Just off the top of my head, I'd suggest installing pip 3.7 and then using it to upgrade itself via

pip install --upgrade pip

This looks the same as How do I update pip itself from inside my virtual environment? on StackOverflow.

  • But then I'll have to keep both python37 and python39 on my installation, because removing python37 also removes pip-3.7 (using the pkg command).
    – DannyNiu
    Mar 2, 2021 at 2:39
  • That's somewhat acceptable if I'm able to install pip packages into /usr/local/lib/python3.9/site-packages, so could you expand your answer on this aspect?
    – DannyNiu
    Mar 2, 2021 at 2:40
  • I may have overlooked something (not unprecedented) but I believe pip is just another PyPI package. Upgrading Python should not touch your packages, unless you otherwise need more than one version of Python3? Mar 2, 2021 at 3:17
  • I don't need more than 1 version of Python. But I do desire my PyPi packages to be installed in the site-packages directory of the correct version of Python library directory. Which is why I need a pip with a version matching that of python.
    – DannyNiu
    Mar 2, 2021 at 5:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .