`pipenv install` 在 RPi 上超时

`pipenv install` timing out on RPi

我正在尝试在 Raspberry Pi 零 W 上启动 [pipenv][1]。我看到的症状是在尝试 create a tutorial project.[=16 时预期超时=]

诚然,RPi 是一台小机器,但我在过程中监控内存使用情况和交换 space,并没有 运行 内存不足或交换。

知道它试图做什么吗?或者我应该如何调试它?这是堆栈跟踪:

pi@blue-server:~/testdir $ pipenv install requests
Creating a virtualenv for this project…
Using /usr/bin/python3 (3.5.3) to create virtualenv…
Traceback (most recent call last):
  File "/home/pi/.local/lib/python3.5/site-packages/pipenv/vendor/pexpect/expect.py", line 109, in expect_loop
    return self.timeout()
  File "/home/pi/.local/lib/python3.5/site-packages/pipenv/vendor/pexpect/expect.py", line 82, in timeout
    raise TIMEOUT(msg)
pexpect.exceptions.TIMEOUT: <pexpect.popen_spawn.PopenSpawn object at 0xb555c950>
searcher: searcher_re:
0: EOF

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/.local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/home/pi/.local/lib/python3.5/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/pi/.local/lib/python3.5/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/pi/.local/lib/python3.5/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/pi/.local/lib/python3.5/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/pi/.local/lib/python3.5/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/pi/.local/lib/python3.5/site-packages/pipenv/cli.py", line 478, in uninstall
    keep_outdated=keep_outdated,
  File "/home/pi/.local/lib/python3.5/site-packages/pipenv/core.py", line 2077, in do_uninstall
    ensure_project(three=three, python=python)
  File "/home/pi/.local/lib/python3.5/site-packages/pipenv/core.py", line 620, in ensure_project
    three=three, python=python, site_packages=site_packages
  File "/home/pi/.local/lib/python3.5/site-packages/pipenv/core.py", line 569, in ensure_virtualenv
    do_create_virtualenv(python=python, site_packages=site_packages)
  File "/home/pi/.local/lib/python3.5/site-packages/pipenv/core.py", line 936, in do_create_virtualenv
    click.echo(crayons.blue(c.out), err=True)
  File "/home/pi/.local/lib/python3.5/site-packages/pipenv/vendor/delegator.py", line 99, in out
    self.__out = self._pexpect_out
  File "/home/pi/.local/lib/python3.5/site-packages/pipenv/vendor/delegator.py", line 87, in _pexpect_out
    result += self.subprocess.read()
  File "/home/pi/.local/lib/python3.5/site-packages/pipenv/vendor/pexpect/spawnbase.py", line 441, in read
    self.expect(self.delimiter)
  File "/home/pi/.local/lib/python3.5/site-packages/pipenv/vendor/pexpect/spawnbase.py", line 341, in expect
    timeout, searchwindowsize, async_)
  File "/home/pi/.local/lib/python3.5/site-packages/pipenv/vendor/pexpect/spawnbase.py", line 369, in expect_list
    return exp.expect_loop(timeout)
  File "/home/pi/.local/lib/python3.5/site-packages/pipenv/vendor/pexpect/expect.py", line 119, in expect_loop
    return self.timeout(e)
  File "/home/pi/.local/lib/python3.5/site-packages/pipenv/vendor/pexpect/expect.py", line 82, in timeout
    raise TIMEOUT(msg)
pexpect.exceptions.TIMEOUT: <pexpect.popen_spawn.PopenSpawn object at 0xb553a710>
searcher: searcher_re:
    0: EOF
<pexpect.popen_spawn.PopenSpawn object at 0xb553a710>
searcher: searcher_re:
    0: EOF

这是环境信息:

pi@blue-server:~/foo $ uname -a
Linux blue-server 4.14.34+ #1110 Mon Apr 16 14:51:42 BST 2018 armv6l GNU/Linux

pi@blue-server:~/foo $ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 9.4 (stretch)
Release:    9.4
Codename:   stretch

pi@blue-server:~/foo $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

pi@blue-server:~/foo $ free -m
              total        used        free      shared  buff/cache   available
Mem:            433          26         260           3         145         353
Swap:            99           0          99

附加信息

我注意到它在子进程调用中超时。使用 pdb,我将其追溯到命令:

<Command ['/usr/bin/python3.5', '-m', 'pipenv.pew', 'new', 'foo-su43ObVR', '-d', '-p', '/usr/bin/python3.5']>

我尝试从命令行复制该调用并且它成功完成:

pi@blue-server:~/foo $ /usr/bin/python3.5 -m pipenv.pew new 'asdf' -d -p /usr/bin/python3.5
Already using interpreter /usr/bin/python3.5
Using base prefix '/usr'
New python executable in /home/pi/.local/share/virtualenvs/asdf/bin/python3.5
Also creating executable in /home/pi/.local/share/virtualenvs/asdf/bin/python
Installing setuptools, pip, wheel...done.

这看起来很有希望,但我仍然不知道是什么原因导致超时。

TL;DR:解决方法是延长超时时间

解决了。因为 RPi Zero 很慢,所以超时了。根据线索 from the discussion on github,我注意到现在可以使用环境变量来延长默认超时。所以这解决了问题:

pi@blue-server:~/testdir $ export PIPENV_TIMEOUT=500
pi@blue-server:~/testdir $ pipenv install requests