Installing pip on a DSM/Synology

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Installing pip on a DSM/Synology



I've been working on a program using python 3 for the last few months. I've been testing it for some time now and it seems to work as it should. So I've tried to get it up and running on a DSM/Synology(Model: DS209+, Version: DSM 4.2-3259). Sadly I don't know anything about this environment.
So I installed python3 (3.3.2-0005) from the Synology Package Center and got it working. Running my code works.
The only problem is, that my program uses the "requests" library. However I just can't get pip running. For installing pip, I tried to use the following line in PuTTY.


curl -k https://bootstrap.pypa.io/get-pip.py | python3



I'd expect pip to download/install and use it to get the requests library. But then this happens and I have don't know what I did wrong:


The directory '/var/services/homes/admin/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/var/services/homes/admin/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pip
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
100% |################################| 1.3MB 131kB/s
Collecting setuptools
Downloading setuptools-38.2.4-py2.py3-none-any.whl (489kB)
100% |################################| 491kB 305kB/s
Collecting wheel
Downloading wheel-0.30.0-py2.py3-none-any.whl (49kB)
100% |################################| 51kB 296kB/s
Installing collected packages: pip, setuptools, wheel
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.3/distutils/sysconfig.py", line 449, in _init_posix
with open(filename) as file:
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/include/python3.3m/pyconfig.h'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/tmp/tmpdqp31o/pip.zip/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/tmp/tmpdqp31o/pip.zip/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/tmp/tmpdqp31o/pip.zip/pip/req/req_set.py", line 784, in install
**kwargs
File "/tmp/tmpdqp31o/pip.zip/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/tmp/tmpdqp31o/pip.zip/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/tmp/tmpdqp31o/pip.zip/pip/wheel.py", line 247, in move_wheel_files
prefix=prefix,
File "/tmp/tmpdqp31o/pip.zip/pip/locations.py", line 153, in distutils_scheme
i.finalize_options()
File "/usr/local/lib/python3.3/distutils/command/install.py", line 313, in finalize_options
(prefix, exec_prefix) = get_config_vars('prefix', 'exec_prefix')
File "/usr/local/lib/python3.3/distutils/sysconfig.py", line 531, in get_config_vars
func()
File "/usr/local/lib/python3.3/distutils/sysconfig.py", line 456, in _init_posix
raise DistutilsPlatformError(my_msg)
distutils.errors.DistutilsPlatformError: invalid Python installation: unable to open /usr/local/include/python3.3m/pyconfig.h (No such file or directory)



It seems like using sudo -H would fix the issue. However I have no idea how to do that and where to start.
Googling the issue didn't help much either because the things I found where either too vague for me to understand or they had this issue with pip already installed.
I hope this question isn't too vague either.





So your problem is you don't know how to change to sudo session? Login as admin, enter sudo -i in PuTTY terminal, enter admin password, then repeat the installation command.
– hoefling
Dec 10 '17 at 0:48


sudo -i




3 Answers
3



Like @hoefling already mentioned, it's a privilege issue.



Login via SSH


ssh user@synology



and enter user password.



Get admin privileges


sudo su



and enter sudo password.



Get installation file


wget https://bootstrap.pypa.io/get-pip.py



and execute installation file.


python get-pip.py



Let me know if it worked for you.





Thank you very much for your answer. Logging in via SSH works without any problems but when I tried to use sudo I got the following response: -sh: sudo: not found. So I looked up how to install sudo and I found that using ipkg should work. I installed ipkg but when I try to use it, I get the following error: ipkg_conf_init: Failed to create temporary directory '(null)': Permission denied
– user8357325
Dec 15 '17 at 8:18



-sh: sudo: not found


ipkg_conf_init: Failed to create temporary directory '(null)': Permission denied





Only the admin or a user with admin rights can install software. Make sure you do have admin rights. The easiest way to make sure about that is to use ssh admin@synonlogy. Then you should be able to enable sudo -i or sudo -su or whatever. Let me know if that worked for you!
– anonjnr
Dec 15 '17 at 9:21


ssh admin@synonlogy


sudo -i


sudo -su





Please make sure you execute the .py with admin rights. For example with ‘sudo python get-pip.py’. Let me know if this worked for you! If not, please post the error message.
– anonjnr
May 23 at 18:14






Man, you have two versions of python installed. Use ‘sudo python2.7 get-pip.py’ and see if it works. If yes, read up on how to get rid of the old version. Depending on the OS it’s not very simple. Hit me up if you need help with that! When two versions are specified, opening python usually gets you to the version that has been there first. In your case to python2.7. Sorry I’m currently on mobile. :)
– anonjnr
May 23 at 18:27




Just logon into synology over ssh to user admin right, then
sudo -i



and here what i get after success login into root:


root@x:~# curl -k https://bootstrap.pypa.io/get-pip.py | python3
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1558k 100 1558k 0 0 1076k 0 0:00:01 0:00:01 --:--:-- 1076k
Collecting pip
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 506kB/s
Collecting setuptools
Downloading setuptools-38.4.0-py2.py3-none-any.whl (489kB)
100% |████████████████████████████████| 491kB 1.1MB/s
Collecting wheel
Using cached wheel-0.30.0-py2.py3-none-any.whl
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-9.0.1 setuptools-38.4.0 wheel-0.30.0





This worked for me, but at the end, I got the message that the scripts were placed in /volume1/@appstore/py3k/usr/local/bin/ and were not in my normal search path. For now, I symlinked them to /usr/local/bin.
– ithos67
Jul 1 at 22:43


/volume1/@appstore/py3k/usr/local/bin/


/usr/local/bin



When using a new venv pip is available automatically. For example:


user@host:~$ python3 -m venv env
user@host:~$ . env/bin/activate
(env) user@host:~$ pip --version
pip 7.1.2 from /volume1/homes/user/env/lib/python3.5/site-packages (python 3.5)



After that you can upgrade pip to the current version:


user@host:~$ pip install --upgrade pip
...
Successfully installed pip-18.0



This also has the advantage that installing packages with pip cannot break the system python.



To automatically activate your environment you can create a .profile:


.profile


user@host:~$ touch ~/.profile
user@host:~$ chmod u=rwx ~/.profile



and then make the content of it look like this:


#!/bin/sh
. env/bin/activate






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard