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.
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
:
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