在过去的几个月里,我一直在开发一个使用python3的程序。我已经对它进行了一段时间的测试,它似乎可以正常工作。所以我试着在DSM /Synology(型号: DS209+,版本:DSM4.2-3259)上启动并运行它。遗憾的是,我对这个环境一无所知。因此,我从Synology Package Center安装了python3 (3.3.2-0005),并使其正常工作。运行我的代码是可行的。唯一的问题是,我的程序使用了“request”库。然而,我就是不能让pip运行。为了安装pip,我尝试在PuTTY中使用以下代码行。
curl -k https://bootstrap.pypa.io/get-pip.py | python3我希望pip下载/安装并使用它来获取请求库。但是后来发生了这样的事情,我不知道我做错了什么:
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)看起来使用sudo -H可以解决这个问题。然而,我不知道如何做到这一点,从哪里开始。用谷歌搜索这个问题也没有多大帮助,因为我发现的东西要么太模糊了,我无法理解,要么他们已经安装了pip的这个问题。我希望这个问题也不要太含糊。
发布于 2018-08-11 05:27:40
当使用新的venv pip时,它会自动可用。例如:
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)之后,您可以将pip升级到当前版本:
user@host:~$ pip install --upgrade pip
...
Successfully installed pip-18.0这也有一个好处,即使用pip安装包不会破坏系统python。
要自动激活您的环境,您可以创建.profile
user@host:~$ touch ~/.profile
user@host:~$ chmod u=rwx ~/.profile然后让它的内容看起来像这样:
#!/bin/sh
. env/bin/activate发布于 2017-12-14 18:16:30
就像@hoefling已经提到的,这是一个特权问题。
通过SSH登录
ssh user@synology并输入用户密码。
获取管理员权限
sudo su然后输入sudo密码。
获取安装文件
wget https://bootstrap.pypa.io/get-pip.py并执行安装文件。
python get-pip.py让我知道它是否对你有效。
发布于 2018-01-27 21:34:47
Login to DSM with root permission via SSH/Telnet
使用您的管理员帐户:ssh admin@synology.fqdn.example.net
sudo -i切换到根目录。以超级用户身份成功登录后,您将拥有安装pip所需的权限
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.0https://stackoverflow.com/questions/47649902
复制相似问题