One of the advantages of installing python in your Synology is that you can write and schedule python scripts.
In this post I will show you how to get python 3.9 running, but in a future post I will show you how to schedule it.
Enable Home for all users
First, lets enable home for all users. That is where your python scripts will reside.
I recommend you to disable SSH when you are done because it disables 2 factor auth and makes your synology more vulnerable.
Go to Control Panel > Terminal & SNMP > Terminal tab:
- Check “Enable SSH service”
- Click “Apply”
Before we run SSH, we need to know the IP of the server:
So now Press the windows icon and type cmd to start the cmd prompt and type:
username is your admin username.
Enter your admin password and you are in!
All synologies come with python 2 pre-install, but we want to use python 3. Lets upgrade it from the package center:
You will find your python 3.9 here:
If you look in the site-packages directory, you will see it is empty:
so we need to install pip.
Either add the python3.9 to PATH or specify it when installing.
Sudo makes it available for all users. Your choice.
sudo /volume1/\@appstore/Python3.9/usr/bin/python3.9 -m ensurepip
Check if it has been installed:
You should see pip there:
Update the pip, setuptools and wheel packages:
sudo /volume1/\@appstore/Python3.9/usr/bin/python3.9 -m pip install --upgrade pip setuptools wheel
And now install virtual environment:
sudo /volume1/\@appstore/Python3.9/usr/bin/python3.9 -m pip install virtualenv
and verify it is there:
Now we are going to create a folder on our home directory
If you now navigate to your Home folder, you will see the folder there:
Navigate to the folder:
and create the virtual environment:
Note: elenv is the name of our virtual environment.
python3 -m venv elenv
And now you can activate it:
Now that we are inside the environment we can install the packages we need.
The easiest way to get this done is to create a requirements.txt file and save it on your el_tracker project folder.
This is how the file looks like:
To get all those packages installed at once:
pip install -r requirements.txt
Now you installed everything:
- Close the cmd window
- Disable SSH
- Make sure 2FA is still enabled
and happy python coding!
On my next post I will show you how to schedule your python script on your NAS.
4 thoughts on “Install and use Python 3.9 in your Synology”
Thanks Ruth, much appreciated. I will be happy if you continue where you left, writing very useful guides.
I have wondered how to utilize my Synology NAS to host Python. I`m looking forward to the next post.
If I may wish for more, I would love to see a Python set up including Flask.
I will! I want to do flask too, but I haven’t figured it out yet and I am locked with other projects, but as soon as I crack it, I will post about it.
Next post I will show how to schedule the scripts and then how to post to a website without flask. Soooo cool 🙂
Awesome guide! much appreciate it 🙂
Question though. If I already have a venv from Pycharm saved locally on the Synology, is it possible to simply index that venv and run it for a scheduled task?
Yes! It works for me (reference to other venv)