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...
鉅婽raceback (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'
Hey @SergeyPirogov, I'm currently unable to reproduce this on a fresh install of 14.04. The $HOME environment variable should be present in a standard install.
From the traceback though, it looks like you might be running this in PyCharm? I'm wondering if the os.environ state could possibly be different there?
Either way, could you confirm for me if typing $HOME
in your shell returns /home/sergey/
? Could you also try running the tox file with export HOME=/home/sergey
for me and see if that fixes the issue?
Thanks!
Nope, It doesn't help
I run into the same error on OS X. I tried it in Fish and Bash. I also did the explizit export of HOME, but it didn't help. I get the same error as @SergeyPirogov.
So I still need to know what the value of $HOME is for you two. Could you also provide the version of pew and pipenv you have installed?
$HOME = /home/sergey
pipenv (3.5.0)
pew (0.1.26)
I have tried it with pipenv 3.5.0 and 3.4.2. I have pew 0.1.26 installed. The value of my $HOME is "/Users/oa" as I am on a Mac OS X machine.
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.
Before we get too far out, @oliverandrich can you confirm you're also seeing this specifically in tox?
Also would you both be able to add this to the script (or tox commands) you're using and send me the output?
python -c "import os; print(os.environ)"
If you're not comfortable posting that here, feel free to email it to me (nate.prewitt at gmail).
Yes, I can confirm, that I see this problem only in tox. Running my tests manually or via travis ci works like a charm.
py27 runtests: commands[0] | python -c import os; print(os.environ)
{'PYTHONHASHSEED': '434770919', 'VIRTUAL_ENV': '/home/sergey/PycharmProjects/webdriver_manager/.tox/py27', 'PATH': '/home/sergey/PycharmProjects/webdriver_manager/.tox/py27/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin', 'LANG': 'en_US.UTF-8', 'DISPLAY': ':0'}
I had the same problem, I fixed it adding:
passenv =
HOME
to the [testenv]
section of tox configuration.
I'm using pipenv
+ pyenv
+ tox
.
Yes, this works for me too
Ok, great! I'm closing this then because I think @edubxb solution seems like the appropriate action in this case. Thanks everyone!
@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.
@oliverandrich yep this is on my list for today 馃槉
Most helpful comment
Yes, this works for me too