Python >=3.5.3 on Synology

When PIP tries to install the (necessary) cryptography package, it needs to compile some C sources. This fails if there is no gcc on the NAS.

Anyone has a dummy guide how to make it happen? I have a DS215 and I can’t even install the v0.64 … I have HA on raspberry but the SD card keeps dying…

Hail to the king who makes a HA package for 215j and the likes, including the python with all its crypto packages etc compiled within it. I got no compiling ability and 0.73.1 isnt cutting it for my tado setup!

On my installation there was folder permission issue - files that should generate on script start were missing and webpage did not work. Solution was changing folder owner back to root

This is the latest step I’ve gotten to. It looks like I cannot install docker as Docker doesn’t have ARM support yet.

I’ve installed GCC using the approach taken here (because I run arm)

That still didn’t help so I manually installed cffi
./python3 -m pip install cffi
this works, however homeassistant still fails.

Trying cffi==1.13.2 shows a new error:
unable to execute ‘/spksrc/toolchains/syno-armada38x-5.2/work/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gcc’: No such file or directory

Which looks like python using the wrong folder to compile my code.
cc=gcc didn’t solve this.

So I used ipkg to install python3 (3.7.*) ipkg install python3
this can compile cffi however installing home assistant now failed with

Collecting aiohttp==3.6.1
  Using cached
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  ERROR: Command errored out with exit status 1:
   command: /opt/bin/python3 /opt/local/lib/python3.7/site-packages/pip/_vendor/pep517/ get_requires_for_build_wheel /tmp/tmpxm1sote0
       cwd: /tmp/pip-install-b3y5zf58/aiohttp
  Complete output (10 lines):
  Traceback (most recent call last):
    File "/opt/local/lib/python3.7/site-packages/pip/_vendor/pep517/", line 257, in <module>
    File "/opt/local/lib/python3.7/site-packages/pip/_vendor/pep517/", line 240, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/opt/local/lib/python3.7/site-packages/pip/_vendor/pep517/", line 85, in get_requires_for_build_wheel
      backend = _build_backend()
    File "/opt/local/lib/python3.7/site-packages/pip/_vendor/pep517/", line 76, in _build_backend
      obj = getattr(obj, path_part)
  AttributeError: module 'setuptools.build_meta' has no attribute '__legacy__'
ERROR: Command errored out with exit status 1: /opt/bin/python3 /opt/local/lib/python3.7/site-packages/pip/_vendor/pep517/ get_requires_for_build_wheel /tmp/tmpxm1sote0 Check the logs for full command output.

EDIT: I believe I’m currently encountering this bug:
However I need to go to bed so I cannot investigate.

Looks like aiothttp is now not compiling.
This problem isn’t true of aiohttp==3.6.2
I can get past this using constraints as defined by

The new error is a GCC compile error.
python3 -m pip install cryptography

gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/opt/include/python3.7m -c build/temp.linux-armv7l-3.7/_openssl.c -o build/temp.linux-armv7l-3.7/build/temp.linux-armv7l-3.7/_openssl.o -Wconversion -Wno-error=sign-conversion
build/temp.linux-armv7l-3.7/_openssl.c:498:10: fatal error: openssl/opensslv.h: No such file or directory
#include <openssl/opensslv.h>
compilation terminated.
error: command ‘gcc’ failed with exit status 1

ERROR: Failed building wheel for cryptography
Running clean for cryptography
Failed to build cryptography
ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly

It’s at this point I’ve realized: ipkg is out of support and I need opkg instead: github Entware/Entware/wiki/Install-on-Synology-NAS

Looks like I might be missing some install dependencies not managed by pip currently. so I’ll need to resolve those.

Installing OPKG means I’m scratch. Might as well record the commands I’m running now:

  1. opkg install python3
  2. opkg install python3-pip
  3. pip install --upgrade pip
  4. pip3 install homeassistant

At this point I’m getting errors again.
Grabbing the logs of the errors I see:
unable to execute 'arm-openwrt-linux-gnueabi-gcc': No such file or directory
Whoops. I forgot to reinstall GCC
opkg install gcc
At this point I am now reading through:
github Entware/Entware/wiki/Using-GCC-for-native-compilation
and installing the headers.


  1. pip3 install homeassistant -c constraints
    Now works (constraints are a file with aiohttp==3.6.2 see above)

At this point my installation has succeeded and the setup wiki’s instructions covered my use case.

And staring the daemon yeilds:

Starting Home Assistant ...
/bin/sh: /volume1/homeassistant/home-assistant.log: Permission denied

That’s unfortunate.

I couldn’t get the permissions right on that folder (weird).
So I’ve now moved the install directory to the home directory of the user.
This works and I’m hitting an error

Still trying to determine how to fix this in my case.

After openssl-1.1.1 worked, HA wanted clib-1.25 and segfaulted.

My solution was to use [] ( and everything worked out of the box (on Raspbian). Only had to configure autostart of the container.

If you can use docker I’m all for it. Unfortunately last I checked I couldn’t use it on an arm device

im a newb and dont have git but while installing i got a dependency error
Install Docker:

# sudo apt-get install docker-ce

fixed it by

Install Docker:
# sudo apt-get install docker-ce -cli
# sudo apt-get install docker-ce

Seems there is a mismatch in de latest 18.09 version of docker-ce /cli

IF using UBUNTU VM 16.04.xx
Pip is not installed for me/ or not working
So i had to do
# sudo apt pip install python3-pip --reinstall

Some help please stucks with the following error whike making the make arch

“please check the messages above” is an important part of your error message. We’d need to see more text above where you clipped.

Are you building in a docker image?

I’m unsure exactly the process you’re doing, but I did some work to make builds a one-line-command therefore less prone to error. Essentially make spk-(PACKAGE)-(ARCH)-(DSM_VER) such as:

git clone && \
    cd spksrc && \
    docker run -it --rm \
      -v $(pwd):/spksrc -w /spksrc  \
      synocommunity/spksrc:latest \
      /bin/bash -c 'make clean && make spk-python3-88f6281-6.1'

(This just ran to completion, but takes 47 minutes on my DS1515)


Just woke up and couldnt leave it alone. I Have the DS213 and the arch code for that is synology_88f6282_213. So i tried relentlessly to build make arch-88f6282.

Turn out 88f6282 does not exist in the Kernel folder (fook my live)
I had to take 88f6281 instead and its building now

THanks for the reply !!! i love the name lol. And also for the comment i was wondering already how to do a fresh run if i fooked up.

#fook2 it was running smootly now i ran out of diskpace. Be sure to allocate enough in de virtualbox

Open Synology Package Center and press the “Manual Install” button.
Click “Browse” and select the Python package we created, then press “Next”.
You will get a unverified package popup, press yes and next screen press Apply.

Line 199 Any idea which package we are talking about ? i only created the 4 whl files atm

Just finished installing the python3 package and than i ran :slight_smile:

/volume1/@appstore/python3/bin/python3 -m venv /volume1/homeassistant/venv-hass

I get the following errors. Help please
Ps i only need to install this python3 version right i uninstalled the DSM store one

/volume1/@appstore/python3/bin/python3 -m venv /volume1/homeassistant/venv-hass
Failed to import the site module
Traceback (most recent call last):
 File "/volume1/@appstore/python3/lib/python3.6/", line 553, in <module>
 File "/volume1/@appstore/python3/lib/python3.6/", line 539, in main
   known_paths = addusersitepackages(known_paths)
 File "/volume1/@appstore/python3/lib/python3.6/", line 282, in addusersitepackages
   user_site = getusersitepackages()
 File "/volume1/@appstore/python3/lib/python3.6/", line 258, in getusersitepackages
   user_base = getuserbase() # this will also set USER_BASE
 File "/volume1/@appstore/python3/lib/python3.6/", line 248, in getuserbase
   USER_BASE = get_config_var('userbase')
 File "/volume1/@appstore/python3/lib/python3.6/", line 601, in get_config_var
   return get_config_vars().get(name)
 File "/volume1/@appstore/python3/lib/python3.6/", line 550, in get_config_vars
 File "/volume1/@appstore/python3/lib/python3.6/", line 421, in _init_posix
   _temp = __import__(name, globals(), locals(), ['build_time_vars'], 0)
ModuleNotFoundError: No module named '_sysconfigdata_m_linux_arm-linux-gnueabi'

Rebuild the py package and noticeed some fails

Stripping bin/busybox... ok
Stripping bin/bzip2... ok
Stripping bin/bzip2recover... ok
Stripping bin/captoinfo... ok
Stripping bin/clear... ok
Stripping bin/curl... ok
Stripping bin/dumpsexp... ok
Stripping bin/easy_install*... failed!
Stripping bin/gpg-error... ok
Stripping bin/hmac256... ok
Stripping bin/idle3.6... failed!
Stripping bin/infocmp... ok
Stripping bin/infotocap... ok
Stripping bin/lzmadec... ok
Stripping bin/lzmainfo... ok
Stripping bin/mpicalc... ok
Stripping bin/openssl... ok
Stripping bin/pip*... failed!
Stripping bin/pydoc3.6... failed!
Stripping bin/python3.6... ok
Stripping bin/python3.6m... ok
Stripping bin/pyvenv-3.6... failed!
Stripping bin/reset... ok
Stripping bin/speexdec... ok
Stripping bin/speexenc... ok
Stripping bin/sqlite3... ok
Stripping bin/tabs... ok
Stripping bin/tic... ok
Stripping bin/toe... ok
Stripping bin/tput... ok
Stripping bin/tset... ok
Stripping bin/wheel... failed!

Any help would be much appreciated

Update to help people from going nuts. I got the above fixed by using the below spksprc to install on my nass. Be sure to :

  • choose the right spk accoording to your NAS model
  • Still have to make the Wheel files so follow chickenporn guide for that
  • For some reason the whl files created for me were named xxx.36 instead of xxx.35 i had to change the script abit for this (7zp command and installing on the NAS)
    Hope it helps

Below file is a python package you can install on your nas

didnt work either

wel didnt succeed anywhere. I noticed while buidling the docker we are useing the command arch=amd64 should this be change too arch=arm64.

I tried arm-64 but docker-ce wont install lol. Im just looking for a stable version to run anyone ?

– Part1 –

I just succeeded to install the latest version of HA on my DS216J (with the help of this topic) and it runs without any errors. This is what I did:

Install Python module and Perl packages.

increase temp space: mount -o remount,size=5G /tmp/ (512 Mb of temp space is to little to run HA, it needs more for building the interface)

sudo -i

Install entware using more or less this tutorial: However point 3 I have replaced by:

wget (take the correct version, to get info about your kernel do uname -r)
chmod 744 ./

Now install the packages needed:

opkg install python3-dev
opkg install python3-pip
opkg install gcc
opkg install make
opkg install libopenssl
opkg install libopenssl-conf
opkg install openssl-util
opkg install python3-pyopenssl
pip install --upgrade pip
pip3 install --upgrade PyNaCl==1.3.0
export CFLAGS=-pthread

1 Like

– Part2 –

next is needed for ffi.h:

cd /opt/lib
tar -xvf libffi-3.2.1.tar.gz
cd libffi-3.2.1
source /opt/bin/
./configure --prefix=/opt
make install

next is needed for opensslv.h

tar -xvf openssl-1.1.1d.tar.gz
cd openssl-1.1.1d
source /opt/bin/
./config --prefix=/opt
make install

next is needed for references in the installation of HA:

mkdir /usr/include
cd /usr/include
ln -s /opt/lib/libffi-3.2.1/include/ffi.h ffi.h
ln -s /opt/lib/libffi-3.2.1/include/ffitarget.h ffitarget.h
ln -s /opt/include/openssl openssl

1 Like

– Part3 –

Start installation of HA:

pip3 install -I --no-cache-dir homeassistant

rm /opt/lib/libffi-3.2.1.tar.gz
rm /opt/lib/openssl-1.1.1d.tar.gz

Start HA by the script from this page:

A tip if you expose HA to the outside using the reverse proxy of synology, add these two variables to the header:

Name - Value
Upgrade - $http_upgrade
Connection - $connection_upgrade

1 Like

Python 3.6.8 is available for Synology from the SynoCommunity. This version is not available from the Synology Package Center which still offers 3.5.6. Instead the .spk file needs to be downloaded from

First verify your processor in the Control Panel Info Center. Mine is an Armadaxp for example. So I downloaded a file for armadaxp. Use the Manual Install button in the Package Center to install that file you downloaded.

The Python executables will end up in /usr/local/python3/bin Note that all current versions of homeassistant will run on 3.6, but ‘soon’ homeassistant will require 3.7

@spokin : You are my hero !!!

Everything installed and running perfectly with the last HA version on my DS115J !!!

Finally I can stop consuming more electricity running HA on a one more separate device.

Thanks for your job man.

If anyone could make a Synology package with this and explain how to use Zigbee2MQTT runing HA directly on Synology, it would be perfect


Thanks for the addition. I have updated my post.