`pipenv install`超时RPi

时间:2018-05-17 03:18:05

标签: python-3.x raspberry-pi pexpect pipenv

我试图在Raspberry Pi Zero W上调出[pipenv][1]。我看到的症状是,在尝试create a tutorial project时pexpect超时。

不可否认,RPi是一台小型机器,但在此过程中我正在监控内存使用情况和交换空间,并且内存或交换时间不足。

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

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.

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

1 个答案:

答案 0 :(得分:4)

TL; DR:修复是延长超时

解决了它。因为RPi Zero很慢,所以它超时了。找一条线索from the discussion on github,我注意到它现在可以用环境变量扩展默认超时。所以这解决了这个问题:

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