Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`pipenv install` timing out on RPi

I'm trying to bring up [pipenv][1] on a Raspberry Pi Zero W. The symptom I'm seeing is that pexpect times out when trying to create a tutorial project.

Admittedly, the RPi is a small machine, but I was monitoring memory usage and swap space during the process, and it wasn't running out of memory or swap.

Any idea what it was trying to do? Or how I should debug this? Here's the stack trace:

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

Here's the environment info:

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

additional info

I noticed it was timing out inside of a subprocess call. Using pdb, I traced it down to the command:

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

I tried replicating that call from the command line and it completed without error:

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.

That seems hopeful, but I still don't know what causes the timeout.

like image 466
fearless_fool Avatar asked May 17 '18 03:05

fearless_fool


People also ask

What is the difference between pip install and Pipenv install?

While pip can install Python packages, Pipenv is recommended as it's a higher-level tool that simplifies dependency management for common use cases. This does a user installation to prevent breaking any system-wide packages.

Does Pipenv install use Pipfile or Pipfile lock?

Use a Pipenv projectPipenv will read the Pipfile and Pipfile. lock files for the project, create the virtual environment, and install all of the dependencies as needed.

Does Pipenv need requirements txt?

Does Pipenv use requirements txt? If you only have a requirements. txt file available when running pipenv install , pipenv will automatically import the contents of this file and create a Pipfile for you.

What is pip install Pipenv?

Last modified: 23 September 2022. Pipenv is a tool that provides all necessary means to create a virtual environment for your Python project. It automatically manages project packages through the Pipfile file as you install or uninstall packages. Pipenv also generates the Pipfile.


1 Answers

TL;DR: the fix is to extend the timeout

Solved it. Because the RPi Zero is slow, it was timing out. Taking a clue from the discussion on github, I noticed that its now possible to extend the default timeout with environment variables. So this solved the problem:

pi@blue-server:~/testdir $ export PIPENV_TIMEOUT=500
pi@blue-server:~/testdir $ pipenv install requests
like image 106
fearless_fool Avatar answered Nov 15 '22 09:11

fearless_fool