Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'pipenv clean' fails when running in an existing virtualenv #3231

rectalogic opened this issue Nov 15, 2018 · 2 comments

'pipenv clean' fails when running in an existing virtualenv #3231

rectalogic opened this issue Nov 15, 2018 · 2 comments


Copy link

@rectalogic rectalogic commented Nov 15, 2018

Issue description

I create and activate my own virtualenv, pipenv reports it is running in an existing virtualenv. I install a package and then run pipenv clean which fails (it attempts to decode an empty string as JSON).

Expected result

pipenv should clean the existing virtualenv

Actual result

Raises exception.

I set a breakpoint where it loads the json, and it looks like it created it's own virtualenv instead of using the active one:

(env) cureatr@cureatr-vm /tmp/testing> ~/.local/bin/pipenv clean
> /home/cureatr/.local/lib/python2.7/site-packages/pipenv/
-> path = json.loads(path.strip())
(Pdb) p path
(Pdb) p self.python
(Pdb) p sys.executable
(Pdb) p self.is_venv
(Pdb) p self.prefix

However /home/cureatr/.local/share/virtualenvs directory is empty.

Steps to replicate

cureatr@cureatr-vm /tmp/testing> pip install --user pipenv
Collecting pipenv
  Using cached
Requirement already satisfied: enum34; python_version < "3" in /usr/lib/python2.7/dist-packages (from pipenv) (1.1.6)
Requirement already satisfied: virtualenv in /usr/local/lib/python2.7/dist-packages (from pipenv) (16.0.0)
Collecting typing; python_version < "3.5" (from pipenv)
  Using cached
Requirement already satisfied: certifi in /usr/local/lib/python2.7/dist-packages (from pipenv) (2018.8.24)
Collecting virtualenv-clone>=0.2.5 (from pipenv)
  Using cached
Requirement already satisfied: pip>=9.0.1 in /usr/local/lib/python2.7/dist-packages (from pipenv) (18.1)
Collecting setuptools>=36.2.1 (from pipenv)
  Using cached
Installing collected packages: typing, virtualenv-clone, setuptools, pipenv
  The script virtualenv-clone is installed in '/home/cureatr/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  The scripts pipenv and pipenv-resolver are installed in '/home/cureatr/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pipenv-2018.11.14 setuptools-40.6.2 typing-3.6.6 virtualenv-clone-0.4.0

cureatr@cureatr-vm /tmp/testing> virtualenv env
New python executable in /tmp/testing/env/bin/python
Installing setuptools, pip, wheel...done.
cureatr@cureatr-vm /tmp/testing> source env/bin/activate

(env) cureatr@cureatr-vm /tmp/testing> ~/.local/bin/pipenv --venv
Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
No virtualenv has been created for this project yet!

(env) cureatr@cureatr-vm /tmp/testing> ~/.local/bin/pipenv install six
Creating a Pipfile for this project...
Installing six...
Adding six to Pipfile's [packages]...
✔ Installation Succeeded
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
✔ Success!
Updated Pipfile.lock (060c30)!
Installing dependencies from Pipfile.lock (060c30)...
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 1/1 — 00:00:00

(env) cureatr@cureatr-vm /tmp/testing> ~/.local/bin/pipenv clean
Traceback (most recent call last):
  File "/home/cureatr/.local/bin/pipenv", line 11, in <module>
  File "/home/cureatr/.local/lib/python2.7/site-packages/pipenv/vendor/click/", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/cureatr/.local/lib/python2.7/site-packages/pipenv/vendor/click/", line 717, in main
    rv = self.invoke(ctx)
  File "/home/cureatr/.local/lib/python2.7/site-packages/pipenv/vendor/click/", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/cureatr/.local/lib/python2.7/site-packages/pipenv/vendor/click/", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/cureatr/.local/lib/python2.7/site-packages/pipenv/vendor/click/", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/cureatr/.local/lib/python2.7/site-packages/pipenv/vendor/click/", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/home/cureatr/.local/lib/python2.7/site-packages/pipenv/vendor/click/", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/cureatr/.local/lib/python2.7/site-packages/pipenv/vendor/click/", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/cureatr/.local/lib/python2.7/site-packages/pipenv/cli/", line 620, in clean
    do_clean(ctx=ctx, three=state.three, python=state.python, dry_run=dry_run)
  File "/home/cureatr/.local/lib/python2.7/site-packages/pipenv/", line 2619, in do_clean
    in project.environment.get_installed_packages()
  File "/home/cureatr/.local/lib/python2.7/site-packages/pipenv/", line 281, in get_installed_packages
    workingset = self.get_working_set()
  File "/home/cureatr/.local/lib/python2.7/site-packages/pipenv/", line 390, in get_working_set
    working_set = pkg_resources.WorkingSet(self.sys_path)
  File "/home/cureatr/.local/lib/python2.7/site-packages/pipenv/vendor/", line 35, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/home/cureatr/.local/lib/python2.7/site-packages/pipenv/", line 197, in sys_path
    path = json.loads(path.strip())
  File "/usr/lib/python2.7/json/", line 339, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/", line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/", line 382, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

$ pipenv --support

Pipenv version: '2018.11.14'

Pipenv location: '/home/cureatr/.local/lib/python2.7/site-packages/pipenv'

Python location: '/usr/bin/python'

Python installations found:

  • 3.6.6: /usr/bin/python3.6
  • 3.6.6: /usr/bin/python3.6m
  • 2.7.15rc1: /usr/bin/python2.7

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '0',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '4.15.0-36-generic',
 'platform_system': 'Linux',
 'platform_version': '#39-Ubuntu SMP Mon Sep 24 16:19:09 UTC 2018',
 'python_full_version': '2.7.15rc1',
 'python_version': '2.7',
 'sys_platform': 'linux2'}

System environment variables:

  • USER
  • PATH
  • HOME
  • PS1
  • LANG
  • TERM
  • PWD
  • TMUX
  • _
  • MAIL

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
  • SHELL: /bin/bash
  • LANG: en_US.UTF-8
  • PWD: /tmp/testing

Copy link

@duplicate-issues duplicate-issues bot commented Nov 15, 2018

Hey @rectalogic,

We did a quick check and this issue looks very darn similar to

This could be a coincidence, but if any of these issues solves your problem then I did a good job 😄

If not, the maintainers will get to this issue shortly.

Your Friendly Neighborhood ProBot

Copy link

@techalchemy techalchemy commented Nov 19, 2018

@frostming just to be clear, we won't clean system packages with your fix, right? I'm not actually sure it is desired to clean packages from a non-pipenv controlled virtualenv

/cc @uranusjr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants