Wouter Wouter - 3 months ago 51x
Linux Question

Python at Synology, how to get Python3 modules installed and where is Python2.7 installed?

Can you please advise me how to get Python3 with modules running at my Synology (DS214play, with DSM 6.0.1-7393 Update 1)?
What I want: run Tweepy and other modules in Python3 on my Synology.

Where I am stuck:

  1. how to get PIP3 to install Tweepy, if I try I get:
    Requirement already up-to-date: pip in /usr/lib/python2.7/site-packages

    Apparently I have a Python 2.7 installed but I was not aware...

    root@DiskStation:/volume1/@appstore/python3/include# ls
    get-pip.py python3.4m
    root@DiskStation:/volume1/@appstore/python3/include# python3 get-pip.py
    -ash: python3: command not found
    root@DiskStation:/volume1/@appstore/python3/include# python get-pip.py
    Requirement already up-to-date: pip in /usr/lib/python2.7/site-packages

  2. So to get PIP3 to work I need to understand where Python2.7 is installed and maybe even how to remove it (if this is necessary).

  3. And it would be good to know which Python3 package would be best to use (default from Synology DSM package manager or the SynoCommunity Python3 pacakge)

Because I can see Python3 in the DSM package manager and in the related folders when connected with SSH (using PuTTY) to my Synology.

But I do not see any package for Python2.7 (which I believe must be there) and I cannot find any Python 2.7 folders when connected with SSH even tough I have the hint that there must be a " /usr/lib/python2.7/site-packages " folder somewhere...

-> The default Python3 from Synology DSM package manager is in a py3k folder:

admin@DiskStation: /volume1/@appstore/py3k/usr/local/bin$

-> the SynoCommunity Python3 package installs in a different place:

admin@DiskStation: /volume1/@appstore/python3$ ls
bin etc include install.log lib openssl.cnf share
admin@DiskStation: /volume1/@appstore/python3/bin$ ls
2to3 busybox bzfgrep bzmore delgroup fatattr infocmp lzmainfo pip3 python3.4 reset start-stop-daemon tset virtualenv-3.4 xz
2to3-3.4 bzcat bzgrep captoinfo deluser gpg-error infotocap mpicalc pip3.4 python3.4m shuf tabs unlink wheel xzcat
addgroup bzcmp bzip2 clear dumpsexp hmac256 lzcat nice pydoc3 pyvenv speexdec tic unlzma xmlcatalog xzdec
adduser bzdiff bzip2recover c_rehash easy_install idle3 lzma openssl pydoc3.4 pyvenv-3.4 speexenc toe unxz xmllint
bunzip2 bzegrep bzless curl easy_install-3.4 idle3.4 lzmadec pip python3 renice sqlite3 tput virtualenv xsltproc
admin@DiskStation:/volume1/@appstore/python3/bin$ python3
-sh: python3: command not found

What I have done:

I installed Python3 using the Synology DSM package manager and then connected with SSH (using PuTTY) to my Synology and set the PATH and used PIP to install Tweepy and other modules.

I believe it was with some commands like: (unfortunately mostly copy pasted without knowing exactly what it means in detail...)

root@DiskStation:~# curl -k https://bootstrap.pypa.io/get-pip.py | python
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1488k 100 1488k 0 0 1577k 0 --:--:-- --:--:-- --:--:-- 1577k
Collecting pip
Using cached pip-8.1.2-py2.py3-none-any.whl
Collecting setuptools
Downloading setuptools-23.1.0-py2.py3-none-any.whl (435kB)
100% |████████████████████████████████| 440kB 551kB/s
Collecting wheel
Using cached wheel-0.29.0-py2.py3-none-any.whl
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-8.1.2 setuptools-23.1.0 wheel-0.29.0

I was able to run scripts based on this and quite happy. Until I got some (Unicode) errors and from the error log saw that it is a 2.7 version of Python that runs on my Synology. It seems these Unicode issues are solved in Python3 (which I have on my PC as well) so I would like to have Python3 on Synology as well.

And the 2.7 version is indeed installed, if I connect with SSH and type Python I get:

admin@DiskStation:~$ python
Python 2.7.11 (default, May 13 2016, 05:16:12)
[GCC 4.9.3 20150311 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

This is strange because I do not see any Python 2.7 package at Synology in the package manager so I must have installed 2.7 through some SSH command that I intended just for PIP.

I had the default Python3 package at Synology installed and if I type
admin@DiskStation:~$ python3

I did get the python3 ready to work with.

Within the /volume1/@appstore/py3k/ I see all kinds of Python and PIP versions and the python3 works well. However without any modules and the PIP3 does not work ("command not found"), I tried it from all possible directories and in all kinds of formats as suggested on similar Q&As e.g.
pip3.4 install tweepy, pip3 install tweepy, etc.

So now using the DSM package manager I have deinstalled Python3 and installed the SynoCommunity Python3 (as suggested on the Synology forum here) which shows a different directory structure. But seems even worse because now I see no references to Python 2.7 anymore (but still it runs so must be there) and even cannot get python3 started:

admin@DiskStation:~$ cd /volume1
admin@DiskStation:/volume1$ cd @appstore
admin@DiskStation:/volume1/@appstore$ cd python3
admin@DiskStation:/volume1/@appstore/python3$ ls
bin etc include install.log lib openssl.cnf share
admin@DiskStation:/volume1/@appstore/python3$ cd bin
admin@DiskStation:/volume1/@appstore/python3/bin$ ls
2to3 bzcmp bzless deluser idle3 lzmainfo pydoc3 renice tabs unxz xz
2to3-3.4 bzdiff bzmore dumpsexp idle3.4 mpicalc pydoc3.4 reset tic virtualenv xzcat
addgroup bzegrep captoinfo easy_install infocmp nice python3 shuf toe virtualenv-3.4 xzdec
adduser bzfgrep clear easy_install-3.4 infotocap openssl python3.4 speexdec tput wheel
bunzip2 bzgrep c_rehash fatattr lzcat pip python3.4m speexenc tset xmlcatalog
busybox bzip2 curl gpg-error lzma pip3 pyvenv sqlite3 unlink xmllint
bzcat bzip2recover delgroup hmac256 lzmadec pip3.4 pyvenv-3.4 start-stop-daemon unlzma xsltproc
admin@DiskStation:/volume1/@appstore/python3/bin$ python3
-sh: python3: command not found
admin@DiskStation:/volume1/@appstore/python3/bin$ python
Python 2.7.11 (default, May 13 2016, 05:16:12)
[GCC 4.9.3 20150311 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

So I reached the point to ask for some tips, hints and advice.


I'm not sure you can remove Python 2 altogether, but you can install Python 3 and evoke it specifically instead of Python 2.

First, make sure Python 3 is Installed: Log into your Synology via the web administration and in the 'Package Center' make sure 'Python 3' is installed. (You will find it under 'Developer Tools' within the 'Package Center')

Next, specifically evoke Python 3 by simply calling python3

You could also try using the locate command on your Synology to find the exact location of Python 2. To do this enter the following on your Synology:

ipkg update
ipkg install mlocate

And here is a tutorial on how to use the command: http://www.thegeekstuff.com/2012/03/locate-command-examples/

Good luck!

Also, If you don't have luck on Stack Overflow I'd run over to the Synology Forums for help as well: https://forum.synology.com