pipenv: pipenv tox error

I tried to use pipenv in my project with tox, but got an error: System: Ubuntu 14.04

tox.ini

[tox]
envlist=py27,py34

[testenv]
passenv = DISPLAY CI TRAVIS TRAVIS_*
deps =
    pipenv
    codecov
commands=
   pipenv lock
   pipenv install --dev
   pipenv run py.test

Error:

GLOB sdist-make: /home/sergey/PycharmProjects/webdriver_manager/setup.py
py27 inst-nodeps: /home/sergey/PycharmProjects/webdriver_manager/.tox/dist/webdriver_manager-1.4.4.zip
py27 installed: The directory '/home/sergey/.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.,appdirs==1.4.2,backports.shutil-get-terminal-size==1.0.0,blindspin==2.0.1,click==6.7,click-completion==0.2.1,colorama==0.3.7,configparser==3.5.0,crayons==0.1.2,delegator.py==0.0.8,Jinja2==2.9.5,MarkupSafe==0.23,packaging==16.8,parse==1.8.0,pathlib==1.0.1,pew==0.1.26,pexpect==4.2.1,pipenv==3.5.0,pipfile==0.0.1,psutil==5.1.3,ptyprocess==0.5.1,pyparsing==2.1.10,pythonz-bd==1.11.4,requests==2.13.0,requirements-parser==0.1.0,shutilwhich==1.1.0,six==1.10.0,toml==0.9.2,virtualenv==15.1.0,virtualenv-clone==0.2.6,webdriver-manager==1.4.4
py27 runtests: PYTHONHASHSEED='1109454899'
py27 runtests: commands[0] | pipenv lock
Creating a virtualenv for this project...
⠋Traceback (most recent call last):
  File "/home/sergey/PycharmProjects/webdriver_manager/.tox/py27/bin/pew", line 7, in <module>
    from pew.pew import pew
  File "/home/sergey/PycharmProjects/webdriver_manager/.tox/py27/local/lib/python2.7/site-packages/pew/__init__.py", line 11, in <module>
    from . import pew
  File "/home/sergey/PycharmProjects/webdriver_manager/.tox/py27/local/lib/python2.7/site-packages/pew/pew.py", line 24, in <module>
    from pythonz.commands.install import InstallCommand
  File "/home/sergey/PycharmProjects/webdriver_manager/.tox/py27/local/lib/python2.7/site-packages/pythonz/__init__.py", line 8, in <module>
    from pythonz.define import PATH_HOME_ETC, PATH_PYTHONS
  File "/home/sergey/PycharmProjects/webdriver_manager/.tox/py27/local/lib/python2.7/site-packages/pythonz/define.py", line 10, in <module>
    ROOT = os.environ.get('PYTHONZ_ROOT') or os.path.join(os.environ['HOME'], '.pythonz') if not os.path.abspath(os.path.dirname(__file__)).startswith(SYSTEMWIDE_PATH) else SYSTEMWIDE_PATH
  File "/home/sergey/PycharmProjects/webdriver_manager/.tox/py27/lib/python2.7/UserDict.py", line 23, in __getitem__
    raise KeyError(key)
KeyError: 'HOME'

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 15 (6 by maintainers)

Most upvoted comments

Yes, this works for me too

I had the same problem, I fixed it adding:

passenv =
    HOME

to the [testenv] section of tox configuration.

I’m using pipenv + pyenv + tox.

@oliverandrich yep this is on my list for today 😊

@nateprewitt I would suggest to do an update to the documentation. I have been using tox the first time yesterday, and at the moment everyone who is following the pipenv documentation will run in this problem.

Ok, great! I’m closing this then because I think @edubxb solution seems like the appropriate action in this case. Thanks everyone!

So this seems like it may be related to saghul/pythonz#73. I’m not entirely sure why this is occurring in unix-like environments but it definitely seems related to pew/pythonz.

In the interim setting PIPENV_VENV_IN_PROJECT in your shell environment will move the virtualenv into your project directory and not use pew. That should avoid this code while we debug further. Feel free to investigate but I won’t have time to look at this for a few days.

Thank you both for reporting this issue.