How to Install pip for Python 3.4 on FreeBSD 10.1: A Complete Guide


2 views

When working with FreeBSD 10.1, you'll notice that the default package repositories primarily contain py27-pip for Python 2.7. This can be frustrating when you need pip for Python 3.4 development. The good news is that Python 3.4 actually includes pip by default - it just needs to be properly invoked.

First, verify your Python 3.4 installation:

python3.4 --version

If you get a version number, you're good to proceed. If not, install Python 3.4 first:

pkg install python34

Python 3.4 includes pip as part of its standard library. You can invoke it using:

python3.4 -m ensurepip --upgrade

This will install or upgrade pip for your Python 3.4 installation. After running this command, you should be able to use pip by calling:

python3.4 -m pip install package_name

To make your life easier, add this alias to your shell configuration:

alias pip3.4='python3.4 -m pip'

Now you can simply use:

pip3.4 install package_name

Check that pip is properly installed and working:

python3.4 -m pip --version

You should see output similar to:

pip 9.0.1 from /usr/local/lib/python3.4/site-packages (python 3.4)

It's good practice to upgrade pip to the latest version:

python3.4 -m pip install --upgrade pip

Now you can install packages specifically for Python 3.4:

pip3.4 install numpy
pip3.4 install requests

For project isolation, use venv (included with Python 3.4):

python3.4 -m venv my_project_env
source my_project_env/bin/activate
pip install package_name  # Now uses the virtualenv's pip

If you encounter permission errors, consider using:

pip3.4 install --user package_name

For SSL issues, you may need to:

pkg install ca_root_nss

If you're running FreeBSD 10.1 and need pip for Python 3.4, you might have noticed that the default ports only offer py27-pip for Python 2.7. This can be frustrating, especially since Python 3.4 should include pip by default, but it's not always straightforward.

First, verify that Python 3.4 is installed on your system:

pkg info | grep python34

If it's not installed, you can install it using:

pkg install python34

Python 3.4 includes ensurepip, a module that bootstraps pip into your Python installation. Here's how to use it:

python3.4 -m ensurepip --upgrade

This command will install pip and set it up for Python 3.4. After running it, verify the installation:

pip3.4 --version

If ensurepip doesn't work, you can download and run the official get-pip.py script:

fetch https://bootstrap.pypa.io/get-pip.py
python3.4 get-pip.py

After installation, you might want to add pip to your PATH or create an alias for easier access. Add this to your ~/.cshrc or ~/.profile:

alias pip3.4='/usr/local/bin/pip3.4'

To ensure everything works correctly, try installing a package:

pip3.4 install requests

Then verify the installation:

python3.4 -c "import requests; print(requests.__version__)"

If you encounter permission errors, consider using --user flag:

pip3.4 install --user package_name

For SSL errors, you might need to install security/ca_root_nss:

pkg install ca_root_nss