Categories
Uncategorized

Re-Install pip and virtualenv Packages After Synology Python 3 Upgrade

I posted this initially in the Synology Community Forum, but figured I would re-post it here.

I recently upgraded my Synology Diskstation to Python 3.8.2 via Package Center. However this install doesn’t come with pip or virtualenv site packages. Here are instructions as to how to install them.

Requirements:

  • Install Python 3.8.2 via Synology Package Center
  • Admin access to your Disktation as we’ll be using the sudo command

Add Python 3.8.2 binary directory to your PATH vartiable

If you choose not to do this, be sure to use /volume1/\@appstore/py3k/usr/local/bin/python3 instead of python3 with the steps below.

Open ~/.bash_profile and add the following:

PATH=$PATH:/volume1/\@appstore/py3k/usr/local/bin
export PATH

Now, Add it to ~/.bashrc so it loads when you connect via SSH:

source ~/.bash_profile

Disconnet, then reconnect and verify the command is working and pointing to the correct binary:

~$ which python3
> /volume1/\@appstore/py3k/usr/local/bin/python3

Install pip

Download get-pip.py via curl (instructions from here: https://pip.pypa.io/en/stable/installing/):

~$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

Install pip globally:

~$ sudo python3 get-pip.py

Be sure to use sudo here, as otherwise it will install pip only locally for the user.

Verify pip appears within global python installations site packages:

ls /volume1/@appstore/py3k/usr/local/lib/python3.8/site-packages

Update the pip, setuptools and wheel packages:

sudo python3 -m pip install --upgrade pip setuptools wheel

Install virtualenv

Next, we’ll need to install the virtualenv site package:

sudo python3 -m pip install virtualenv

Verify virtualenv appears within global python installations site packages:

ls /volume1/@appstore/py3k/usr/local/lib/python3.8/site-packages

Now, browse to the directory of your app. We’ll remove the old virtualenv first (assuming it’s called venv):

/volume1/web/mysite$ rm -rf venv

Create new virtual environment:

/volume1/web/mysite$ python3 -m virtualenv venv

You should be all set to start your virtual environment, and get back to Django development.