Python >=3.5.3 on Synology

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:
```bash
# 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 https://github.com/SynoCommunity/spksrc.git && \
    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)

2 Likes

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.

Solution:
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/site.py", line 553, in <module>
   main()
 File "/volume1/@appstore/python3/lib/python3.6/site.py", line 539, in main
   known_paths = addusersitepackages(known_paths)
 File "/volume1/@appstore/python3/lib/python3.6/site.py", line 282, in addusersitepackages
   user_site = getusersitepackages()
 File "/volume1/@appstore/python3/lib/python3.6/site.py", line 258, in getusersitepackages
   user_base = getuserbase() # this will also set USER_BASE
 File "/volume1/@appstore/python3/lib/python3.6/site.py", line 248, in getuserbase
   USER_BASE = get_config_var('userbase')
 File "/volume1/@appstore/python3/lib/python3.6/sysconfig.py", line 601, in get_config_var
   return get_config_vars().get(name)
 File "/volume1/@appstore/python3/lib/python3.6/sysconfig.py", line 550, in get_config_vars
   _init_posix(_CONFIG_VARS)
 File "/volume1/@appstore/python3/lib/python3.6/sysconfig.py", 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

https://github.com/smaarn/spksrc/releases/tag/python-3.6.8-11

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: https://github.com/Entware/Entware/wiki/Install-on-Synology-NAS. However point 3 I have replaced by:

wget http://bin.entware.net/armv7sf-k3.2/installer/generic.sh (take the correct version, to get info about your kernel do uname -r)
chmod 744 ./generic.sh
./generic.sh

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
wget ftp://sourceware.org/pub/libffi/libffi-3.2.1.tar.gz
tar -xvf libffi-3.2.1.tar.gz
cd libffi-3.2.1
source /opt/bin/gcc_env.sh
./configure --prefix=/opt
make
make install

next is needed for opensslv.h

wget https://www.openssl.org/source/openssl-1.1.1d.tar.gz
tar -xvf openssl-1.1.1d.tar.gz
cd openssl-1.1.1d
source /opt/bin/gcc_env.sh
./config --prefix=/opt
make
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: https://www.home-assistant.io/docs/installation/synology/

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 https://synocommunity.com/package/python3

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

@musclorpage

Thanks for the addition. I have updated my post.

opkg will install Python 3.8 and this is running well.

Have you tried pip3 upgrade aiohttp?

OK.
I managed to make everything work and fluant on a DS115J !!!

Just had to wait a little for HA to start.

@spokin : Can you just edit your post to make it clearer for everyone:

– Part1 –

From your Synology Package Center, install

  • Python Module (Not Python 3)
  • Perl


next is needed for opensslv.h
(Complilation may take some time)

– Part2 –

pip3 install sqlalchemy

– Part3 –
Start HA by the script from this page: https://www.home-assistant.io/docs/installation/synology/

cd /volume1/homeassistant

Create hass-daemon file using the following code (edit the variables in uppercase if necessary)

#!/bin/sh

# Package
PACKAGE="homeassistant"
DNAME="Home Assistant"

# Others
USER="homeassistant"
PYTHON_DIR="/opt/bin"
PYTHON="$PYTHON_DIR/python3"
HASS="$PYTHON_DIR/hass"
INSTALL_DIR="/volume1/homeassistant"
PID_FILE="$INSTALL_DIR/home-assistant.pid"
FLAGS="-v --config $INSTALL_DIR --pid-file $PID_FILE --daemon"
REDIRECT="> $INSTALL_DIR/home-assistant.log 2>&1"

start_daemon ()
{
    sudo -u ${USER} /bin/sh -c "$PYTHON $HASS $FLAGS $REDIRECT;"
}

stop_daemon ()
{
    kill `cat ${PID_FILE}`
    wait_for_status 1 20 || kill -9 `cat ${PID_FILE}`
    rm -f ${PID_FILE}
}

daemon_status ()
{
    if [ -f ${PID_FILE} ] && kill -0 `cat ${PID_FILE}` > /dev/null 2>&1; then
        return
    fi
    rm -f ${PID_FILE}
    return 1
}

wait_for_status ()
{
    counter=$2
    while [ ${counter} -gt 0 ]; do
        daemon_status
        [ $? -eq $1 ] && return
        let counter=counter-1
        sleep 1
    done
    return 1
}

case $1 in
    start)
        if daemon_status; then
            echo ${DNAME} is already running
            exit 0
        else
            echo Starting ${DNAME} ...
            start_daemon
            exit $?
        fi
        ;;
    stop)
        if daemon_status; then
            echo Stopping ${DNAME} ...
            stop_daemon
            exit $?
        else
            echo ${DNAME} is not running
            exit 0
        fi
        ;;
        restart)
        if daemon_status; then
            echo Stopping ${DNAME} ...
            stop_daemon
            echo Starting ${DNAME} ...
            start_daemon
            exit $?
        else
            echo ${DNAME} is not running
            echo Starting ${DNAME} ...
            start_daemon
            exit $?
        fi
        ;;
    status)
        if daemon_status; then
            echo ${DNAME} is running
            exit 0
        else
            echo ${DNAME} is not running
            exit 1
        fi
        ;;
    log)
        echo ${LOG_FILE}
        exit 0
        ;;
    *)
        exit 1
        ;;
esac

Make the daemon file executable:

chmod 755 /volume1/homeassistant/hass-daemon

Start Home Assistant:

sudo /volume1/homeassistant/hass-daemon start
1 Like

For now I am not installing packages from Entware because it affects support from Synology. Some years ago I had Optware installed on a Synology. I had to open a ticket with Synology to fix an issue and they refused to work with me until I removed the /opt directory and any trace of the Optware. They have no problem with programs installed via Package Center. Since I only need Python, I will try to stay with installs of .spk packages.

I withdraw my suggestion to use the 3.6.8 Python .spkr package. I have discovered it was withdrawn because it had issues with Home Assistant building openzwave dependencies in the venv environment. Now that current versions of HA need Python 3.7, the community packages are not useful.

I just can’t seem to get this to work. @spokin tried to follow your modified directions since I do want homeassistant in a shared folder where I can easily see the files/configs. I am running synology diskstation 216play. Any help would be greatly appreciated. I am rather new to linux and command prompt / terminal.

I am getting this error:

WARNING: You are using pip version 19.2.3, however version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

When I try to upgrade pip, I get this:

Traceback (most recent call last):
  File "/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
ImportError: No module named pkg_resources

When I try to
sudo pip3 install -I --no-cache-dir homeassistant

I get to installing build dependencies… and the:

 Installing build dependencies ... error
  ERROR: Command errored out with exit status 1:
   command: /opt/bin/python3 /opt/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-c9xgq6ai/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.6.0' wheel 'cffi>=1.8,!=1.11.3; platform_python_implementation != '"'"'PyPy'"'"''
       cwd: None
  Complete output (55 lines):

I can confirm this works on a DS215j with Armada 375 , 2x 800mhz.
I dont run a heavy setup, but it works all without hickups.

1 Like

do this as well
pip3 install --upgrade pip

not the “3” !