A simple recipe for installing the pip utility that is needed to install Python packages/Modules:
This needs to be done with the user root so ssh to the Diskstation with that user.
1st) Install Python from the Package Installer Web interface. I have Python 2.7 installed
2nd) Connect to your Synology NAS through ssh.
3rd) Get the pip installer: wget https://bootstrap.pypa.io/get-pip.py
4th) Execute the installer: python get-pip.py. It will take a while:
# python get-pip.py Collecting pip Downloading pip-8.0.2-py2.py3-none-any.whl (1.2MB) 100% |████████████████████████████████| 1.2MB 42kB/s Collecting setuptools Downloading setuptools-19.6-py2.py3-none-any.whl (472kB) 100% |████████████████████████████████| 475kB 109kB/s Collecting wheel Downloading wheel-0.26.0-py2.py3-none-any.whl (63kB) 100% |████████████████████████████████| 65kB 291kB/s Installing collected packages: pip, setuptools, wheel Successfully installed pip-8.0.2 setuptools-19.6 wheel-0.26.0
We can now execute the pip command:
# pip Usage: pip [options] Commands: install Install packages. download Download packages. uninstall Uninstall packages. freeze Output installed packages in requirements format. list List installed packages. show Show information about installed packages. search Search PyPI for packages. wheel Build wheels from your requirements. hash Compute hashes of package archives. help Show help for commands. ... ...
Now we can install the modules that we need.
For example, installing paho-mqtt for MQTT support:
# pip install paho-mqtt Collecting paho-mqtt Downloading paho-mqtt-1.1.tar.gz (41kB) 100% |████████████████████████████████| 45kB 589kB/s Building wheels for collected packages: paho-mqtt Running setup.py bdist_wheel for paho-mqtt ... done Stored in directory: /var/services/homes/root/.cache/pip/wheels/97/db/5f/1ddca8ee2f9b58f9bb68208323bd39bb0b177f32f434aa4b95 Successfully built paho-mqtt Installing collected packages: paho-mqtt Successfully installed paho-mqtt-1.1
And we can use now the paho.mqtt module on our python programs.
Are you installing pip on the default root administrator directory? I’m getting the following error after running wget:
Connecting to bootstrap.pypa.io|23.235.39.175|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 1511867 (1.4M) [text/x-python]
get-pip.py: Permission denied
Cannot write to ‘get-pip.py’ (Success).
Ah, the issue was that I ssh’d as admin, not root. For this to work you must be root.
Yes, I did it as root. Anyway, I’m adding that note. Thanks for the input.
UPDATE For DSM 6.0 & python3.5
python3.5 -m ensurepip
python3.5 -m pip install flask
😉 Thxer
That worked perfectly. And allowed install of the latest Django with no issues.
Thanks a lot for this information. Paho.mqtt runs now like a charm on my DS416play.
Saudações de Holanda.
Glad it helped 🙂
This is nice, thanks. I used it and it worked for me.
However, when the next DSM came down the line and I allowed my box to update, it seems to have wiped out ‘pip’ and the modules I’d previously downloaded. Is this unavoidable or did I do something incorrectly?
It also happens to me, but I’m not sure if it happens with all updates, or only Python related ones.
Just to add/mention something:
I installed Python3 from Synology packages…
the PIP install can be done with python3.5 get-pip.py but u won’t find something like pip3.5 its always 2.7
you can find the correct pip binary at:
/volume1/@appstore/py3k/usr/local/bin
I even don’t if pip is already installed with 3.5 I didn’t check that beforehand….