Pipenv: `pipenv check` broken with Pip 10

Created on 14 Apr 2018  Â·  20Comments  Â·  Source: pypa/pipenv

With Pip 10, pipenv check fails with an exception in the safety library. The vendored version of safety needs updating; as of 10 days ago, it now supports Pip 10 (c.f. commit pyupio/safety@051c156fcf4272c18ea8aab8c4277efcd56e3c0f).

$ python -m pipenv.help output

Pipenv version: '11.10.0'

Pipenv location: '/home/josh/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv'

Python location: '/home/josh/.local/venvs/pipenv/bin/python'

Other Python installations in PATH:

  • 2.7: /home/josh/systemetric/sr-robot/.venv/bin/python2.7
  • 2.7: /home/josh/systemetric/sr-robot/.venv/bin/python2.7
  • 2.7: /usr/bin/python2.7
  • 3.5: /usr/bin/python3.5m
  • 3.5: /usr/bin/python3.5
  • 3.6: /usr/bin/python3.6m
  • 3.6: /usr/bin/python3.6

  • 2.7.12: /home/josh/systemetric/sr-robot/.venv/bin/python

  • 2.7.12: /usr/bin/python
  • 2.7.12: /home/josh/systemetric/sr-robot/.venv/bin/python2
  • 2.7.12: /usr/bin/python2
  • 3.5.2: /usr/bin/python3

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.6.3',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '4.13.0-38-generic',
 'platform_system': 'Linux',
 'platform_version': '#43~16.04.1-Ubuntu SMP Wed Mar 14 17:48:43 UTC 2018',
 'python_full_version': '3.6.3',
 'python_version': '3.6',
 'sys_platform': 'linux'}

System environment variables:

  • CLUTTER_IM_MODULE
  • PIPENV_VENV_IN_PROJECT
  • PYTHONUNBUFFERED
  • NVM_DIR
  • LS_COLORS
  • GNOME_KEYRING_PID
  • GIT_PS1_SHOWUNTRACKEDFILES
  • XDG_CONFIG_HOME
  • LESSCLOSE
  • LANG
  • GDM_LANG
  • LESS
  • DISPLAY
  • PYENV_ROOT
  • OLDPWD
  • WORKON_HOME
  • EDITOR
  • COMPIZ_CONFIG_PROFILE
  • GTK2_MODULES
  • GPG_TTY
  • UPSTART_INSTANCE
  • PIPENV_SHELL_FANCY
  • DEBFULLNAME
  • XDG_VTNR
  • RIPGREP_CONFIG_PATH
  • SSH_AUTH_SOCK
  • VIRTUAL_ENV
  • MANDATORY_PATH
  • SESSIONTYPE
  • TMUX_PLUGIN_MANAGER_PATH
  • XDG_SESSION_ID
  • XDG_GREETER_DATA_DIR
  • USER
  • DESKTOP_SESSION
  • JOB
  • QT4_IM_MODULE
  • GOPATH
  • PIP_PYTHON_PATH
  • DEFAULTS_PATH
  • QT_QPA_PLATFORMTHEME
  • PWD
  • MANPAGER
  • HOME
  • GIT_PS1_SHOWDIRTYSTATE
  • SSH_AGENT_PID
  • QT_ACCESSIBILITY
  • TMUX
  • XDG_SESSION_TYPE
  • XDG_DATA_DIRS
  • UPSTART_SESSION
  • PIPENV_ACTIVE
  • XDG_SESSION_DESKTOP
  • GIT_PS1_SHOWUPSTREAM
  • GTK_MODULES
  • UPSTART_EVENTS
  • VISUAL
  • VTE_VERSION
  • TERM
  • SHELL
  • GNOME_KEYRING_CONTROL
  • XDG_SEAT_PATH
  • QT_IM_MODULE
  • XMODIFIERS
  • IM_CONFIG_PHASE
  • GIT_PS1_SHOWSTASHSTATE
  • INSTANCE
  • XDG_CURRENT_DESKTOP
  • GPG_AGENT_INFO
  • QT_LINUX_ACCESSIBILITY_ALWAYS_ON
  • TMUX_VERSION
  • TMUX_PANE
  • PYTHONDONTWRITEBYTECODE
  • XDG_SEAT
  • SHLVL
  • LANGUAGE
  • WINDOWID
  • DEBEMAIL
  • GDMSESSION
  • GNOME_DESKTOP_SESSION_ID
  • XDG_CACHE_HOME
  • LOGNAME
  • DBUS_SESSION_BUS_ADDRESS
  • UPSTART_JOB
  • XDG_RUNTIME_DIR
  • XAUTHORITY
  • XDG_DATA_HOME
  • XDG_SESSION_PATH
  • XDG_CONFIG_DIRS
  • PATH
  • MYPYPATH
  • LESSOPEN
  • GTK_IM_MODULE
  • _

Pipenv–specific environment variables:

  • PIPENV_VENV_IN_PROJECT: 1
  • PIPENV_SHELL_FANCY: 1
  • PIPENV_ACTIVE: 1

Debug–specific environment variables:

  • PATH: /home/josh/systemetric/sr-robot/.venv/bin:/home/josh/go/bin:/home/josh/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/josh/.cargo/bin:/home/josh/.cabal/bin:/home/josh/bin:/home/josh/.local/bin
  • SHELL: /bin/bash
  • EDITOR: vim
  • LANG: en_GB.UTF-8
  • PWD: /home/josh/systemetric/sr-robot
  • VIRTUAL_ENV: /home/josh/systemetric/sr-robot/.venv

Contents of Pipfile ('/home/josh/systemetric/sr-robot/Pipfile'):

[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"

[packages]

[dev-packages]
"flake8" = "*"
pytype = {git = "ssh://[email protected]/google/pytype.git"}

[requires]
python_version = "2.7"

Contents of Pipfile.lock ('/home/josh/systemetric/sr-robot/Pipfile.lock'):

{
    "_meta": {
        "hash": {
            "sha256": "1e4788741aca44c08d80c24de2037a2bfddfd51bd917745b626f0ca5dbe2177a"
        },
        "pipfile-spec": 6,
        "requires": {
            "python_version": "2.7"
        },
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.python.org/simple",
                "verify_ssl": true
            }
        ]
    },
    "default": {},
    "develop": {
        "configparser": {
            "hashes": [
                "sha256:5308b47021bc2340965c371f0f058cc6971a04502638d4244225c49d80db273a"
            ],
            "markers": "python_version < '3.2'",
            "version": "==3.5.0"
        },
        "enum34": {
            "hashes": [
                "sha256:2d81cbbe0e73112bdfe6ef8576f2238f2ba27dd0d55752a776c41d38b7da2850",
                "sha256:644837f692e5f550741432dd3f223bbb9852018674981b1664e5dc339387588a",
                "sha256:6bd0f6ad48ec2aa117d3d141940d484deccda84d4fcd884f5c3d93c23ecd8c79",
                "sha256:8ad8c4783bf61ded74527bffb48ed9b54166685e4230386a9ed9b1279e2df5b1"
            ],
            "markers": "python_version < '3.4'",
            "version": "==1.1.6"
        },
        "flake8": {
            "hashes": [
                "sha256:7253265f7abd8b313e3892944044a365e3f4ac3fcdcfb4298f55ee9ddf188ba0",
                "sha256:c7841163e2b576d435799169b78703ad6ac1bbb0f199994fc05f700b2a90ea37"
            ],
            "index": "pypi",
            "version": "==3.5.0"
        },
        "mccabe": {
            "hashes": [
                "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42",
                "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"
            ],
            "version": "==0.6.1"
        },
        "pycodestyle": {
            "hashes": [
                "sha256:1ec08a51c901dfe44921576ed6e4c1f5b7ecbad403f871397feedb5eb8e4fa14",
                "sha256:5ff2fbcbab997895ba9ead77e1b38b3ebc2e5c3b8a6194ef918666e4c790a00e",
                "sha256:682256a5b318149ca0d2a9185d365d8864a768a28db66a84a2ea946bcc426766",
                "sha256:6c4245ade1edfad79c3446fadfc96b0de2759662dc29d07d80a6f27ad1ca6ba9"
            ],
            "version": "==2.3.1"
        },
        "pyflakes": {
            "hashes": [
                "sha256:08bd6a50edf8cffa9fa09a463063c425ecaaf10d1eb0335a7e8b1401aef89e6f",
                "sha256:8d616a382f243dbf19b54743f280b80198be0bca3a5396f1d2e1fca6223e8805"
            ],
            "version": "==1.6.0"
        },
        "pytype": {
            "git": "ssh://[email protected]/google/pytype.git"
        }
    }
}


Expected result

Problems with installed packages' security are printed.

Actual result
$ pipenv check --verbose
Checking PEP 508 requirements…
Passed!
Checking installed package safety…
An error occurred:
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/josh/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/patched/safety.zip/__main__.py", line 8, in <module>
  File "/home/josh/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/patched/safety.zip/click/core.py", line 722, in __call__
  File "/home/josh/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/patched/safety.zip/click/core.py", line 697, in main
  File "/home/josh/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/patched/safety.zip/click/core.py", line 1066, in invoke
  File "/home/josh/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/patched/safety.zip/click/core.py", line 895, in invoke
  File "/home/josh/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/patched/safety.zip/click/core.py", line 535, in invoke
  File "/home/josh/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/patched/safety.zip/safety/cli.py", line 52, in check
AttributeError: 'module' object has no attribute 'get_installed_distributions'
Steps to replicate
$ pipenv check
Type

Most helpful comment

@techalchemy thanks for the quickfix, can you please release it?

All 20 comments

@anowlcalledjosh saw this a bit ago, already working on it, scheduling this for 11.10.1 on monday

thanks for the note and the reference, trying to get our vendoring process a bit more automated to help with this stuff

If anyone needs a fix in the meantime (in our case not being able to deploy without passing checks) just pipenv install pip==9.0.2 in the repository you need. I've spent quite a while looking at system's pip and wondering what's wrong :)

Downgrading pip to <10 worked. But I was confused that it was a pipenv issue, not safety issue.

File "/usr/local/lib/python3.6/site-packages/pipenv/patched/safety.zip/safety/cli.py", line 52, in check

Here's a failing build link: https://travis-ci.org/wemake-services/wemake-django-template/builds/367106163#L777

I resolved this by removing the virtualenv entirely.

Steps:

  1. Update pip in environment

    pipenv run pip install -U pip
    
  2. Update global pip

    pip install --user -U pip
    
  3. Noticed it’s broken

    pipenv sync
    
  4. Remove virtualenv manually

    rm -rf ~/.local/share/virtualenvs/env-name
    
  5. Recreate the env

    pipenv sync
    
  6. It works, and Pip is on 10.0.0

    pipenv run pip --version
    

Hoping to get a release out today with a fix

@sobolevn it _was_ a safety issue, but we bundle safety and they already addressed this so we needed to upgrade it

@techalchemy thanks for the quickfix, can you please release it?

Hello,

Thank you for the work done on pipenv!
Is the fix released?

Jr

Just released a prerelease for testing, will release it for real tomorrow if all is well. Take it for a spin -- pip install --upgrade --pre pipenv

Was this released @techalchemy ? Still seem to be getting this same error when I run pipenv check except mime reads AttributeError: module 'pip' has no attribute 'get_installed_distributions'

@LWanjiru You’re not using --pre. Read the comments.

has it been officially released? @uranusjr

no. Working on 2 small issues before releasing, hoping to release something stable.

cool @techalchemy do let us know when it goes live.
Thank you for the update.

It appears to be in 11.10.1, pipenv check works for me now.

pip install --upgrade pipenv will fix the issue

For those googling, in July 2018:

(While inside a pipenv shell session) I ran pip install --upgrade pip as well as pip install --upgrade pipenv, but it didn't appear to work... I then deactivated the virtual environment. Re-ran pipenv shell, and it ran just fine. đź‘Ť

For those googling, in July 2018:

(While inside a pipenv shell session) I ran pip install --upgrade pip as well as pip install --upgrade pipenv, but it didn't appear to work... I then deactivated the virtual environment. Re-ran pipenv shell, and it ran just fine. +1

This still works, In march 2019.

Was this page helpful?
0 / 5 - 0 ratings