Pipenv: Running pipenv gives TypeError: 'module' object is not callable

Created on 20 Sep 2018  Β·  27Comments  Β·  Source: pypa/pipenv

Issue description

I just installed pipenv on a pyenv installed Python 3.7.0 interpreter. Starting in a clean directory resulted in an exception.

Expected result

pipenv to not crash.

Actual result
$ pip install pipenv
Requirement already satisfied: pipenv in /Users/pradyunsg/.pyenv/versions/3.7.0/lib/python3.7/site-packages (2018.7.1)
Requirement already satisfied: virtualenv-clone>=0.2.5 in /Users/pradyunsg/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from pipenv) (0.3.0)
Requirement already satisfied: pip>=9.0.1 in /Users/pradyunsg/Projects/pip/src (from pipenv) (18.1.dev0)
Requirement already satisfied: setuptools>=36.2.1 in /Users/pradyunsg/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from pipenv) (39.0.1)
Requirement already satisfied: certifi in /Users/pradyunsg/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from pipenv) (2018.8.24)
Requirement already satisfied: virtualenv in /Users/pradyunsg/.pyenv/versions/3.7.0/lib/python3.7/site-packages (from pipenv) (16.0.0)
$ pipenv --version
pipenv, version 2018.7.1
$ pipenv install django --verbose
Creating a Pipfile for this project...
Installing django...
β ‹Installing 'django'
Traceback (most recent call last):
  File "/Users/pradyunsg/.pyenv/versions/3.7.0/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/Users/pradyunsg/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Users/pradyunsg/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Users/pradyunsg/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/pradyunsg/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/pradyunsg/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/pradyunsg/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/cli.py", line 435, in install
    selective_upgrade=selective_upgrade,
  File "/Users/pradyunsg/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/core.py", line 1971, in do_install
    pypi_mirror=pypi_mirror,
  File "/Users/pradyunsg/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/core.py", line 1375, in pip_install
    package_name.split('--hash')[0].split('--trusted-host')[0]
  File "/Users/pradyunsg/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/requirements.py", line 704, in from_line
    line, extras = _strip_extras(line)
TypeError: 'module' object is not callable
Steps to replicate

$ pipenv --support

Pipenv version: '2018.7.1'

Pipenv location: '/Users/pradyunsg/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv'

Python location: '/Users/pradyunsg/.pyenv/versions/3.7.0/bin/python3.7'

Other Python installations in PATH:

  • 2.7: /Users/pradyunsg/.pyenv/shims/python2.7
  • 2.7: /Users/pradyunsg/.pyenv/shims/python2.7
  • 2.7: /usr/local/bin/python2.7
  • 2.7: /usr/bin/python2.7
  • 2.7: /Users/pradyunsg/.pyenv/shims/python2.7
  • 3.4: /Users/pradyunsg/.pyenv/shims/python3.4m
  • 3.4: /Users/pradyunsg/.pyenv/shims/python3.4
  • 3.4: /Users/pradyunsg/.pyenv/shims/python3.4
  • 3.5: /Users/pradyunsg/.pyenv/shims/python3.5m
  • 3.5: /Users/pradyunsg/.pyenv/shims/python3.5
  • 3.5: /Users/pradyunsg/.pyenv/shims/python3.5
  • 3.6: /Users/pradyunsg/.pyenv/shims/python3.6m
  • 3.6: /Users/pradyunsg/.pyenv/shims/python3.6
  • 3.6: /Users/pradyunsg/.pyenv/shims/python3.6
  • 3.7: /Users/pradyunsg/.pyenv/versions/3.7.0/bin/python3.7m
  • 3.7: /Users/pradyunsg/.pyenv/versions/3.7.0/bin/python3.7
  • 3.7: /Users/pradyunsg/.pyenv/shims/python3.7
  • 3.7: /usr/local/bin/python3.7
  • 3.7: /Users/pradyunsg/.pyenv/shims/python3.7

  • 3.7.0: /Users/pradyunsg/.pyenv/versions/3.7.0/bin/python

  • 3.7.0: /Users/pradyunsg/.pyenv/shims/python
  • 2.7.15: /usr/local/bin/python
  • 2.7.10: /usr/bin/python
  • 3.7.0: /Users/pradyunsg/.pyenv/shims/python
  • 2.7.15: /Users/pradyunsg/.pyenv/shims/python2
  • 2.7.15: /usr/local/bin/python2
  • 2.7.15: /Users/pradyunsg/.pyenv/shims/python2
  • 3.7.0: /Users/pradyunsg/.pyenv/versions/3.7.0/bin/python3
  • 3.7.0: /Users/pradyunsg/.pyenv/shims/python3
  • 3.7.0: /usr/local/bin/python3
  • 3.7.0: /Users/pradyunsg/.pyenv/shims/python3

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.7.0',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '17.7.0',
 'platform_system': 'Darwin',
 'platform_version': 'Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT '
                     '2018; root:xnu-4570.71.2~1/RELEASE_X86_64',
 'python_full_version': '3.7.0',
 'python_version': '3.7',
 'sys_platform': 'darwin'}

System environment variables:

  • RBENV_VERSION
  • TERM_PROGRAM
  • VIRTUALENVWRAPPER_SCRIPT
  • PYENV_ROOT
  • TERM
  • SHELL
  • ZPLUG_LOADFILE
  • TMPDIR
  • Apple_PubSub_Socket_Render
  • TERM_PROGRAM_VERSION
  • FPATH
  • PYENV_VERSION
  • DEFAULT_RBENV
  • ZPLUG_USE_CACHE
  • USER
  • ZPLUG_ERROR_LOG
  • ZPLUG_PROTOCOL
  • SSH_AUTH_SOCK
  • PYENV_DIR
  • __CF_USER_TEXT_ENCODING
  • VIRTUAL_ENV_DISABLE_PROMPT
  • _ZPLUG_VERSION
  • _ZPLUG_PREZTO
  • PERIOD
  • _ZPLUG_AWKPATH
  • VIRTUALENVWRAPPER_PYTHON
  • PATH
  • PYENV_VIRTUALENVWRAPPER_PYENV_VERSION
  • PWD
  • LANG
  • PYENV_HOOK_PATH
  • _ZPLUG_CONFIG_SUBSHELL
  • XPC_FLAGS
  • _ZPLUG_OHMYZSH
  • ZPLUG_BIN
  • VIRTUALENVWRAPPER_VIRTUALENV
  • _ZPLUG_URL
  • RBENV_SHELL
  • HISTIGNORE
  • HISTCONTROL
  • XPC_SERVICE_NAME
  • GPG_TTY
  • ZPLUG_CACHE_DIR
  • SHLVL
  • PYENV_SHELL
  • HOME
  • _VIRTUALENVWRAPPER_API
  • ZPLUG_THREADS
  • ZPLUG_REPOS
  • LOGNAME
  • VIRTUALENVWRAPPER_VIRTUALENV_CLONE
  • ZPLUG_FILTER
  • ZPLUG_HOME
  • ZPLUG_ROOT
  • SECURITYSESSIONID
  • VIRTUALENVWRAPPER_LAZY_SCRIPT
  • HISTFILE
  • PYTHONDONTWRITEBYTECODE
  • PIP_PYTHON_PATH

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: /Users/pradyunsg/.pyenv/versions/3.7.0/bin:/usr/local/Cellar/pyenv/1.2.7/libexec:/Users/pradyunsg/.rbenv/shims:/Users/pradyunsg/.pyenv/shims:/usr/local/Cellar/zplug/2.4.2/bin:/usr/local/opt/zplug/bin:/Users/pradyunsg/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/pradyunsg/.rbenv/shims:/Users/pradyunsg/.pyenv/shims:/Applications/Visual Studio Code.app/Contents/Resources/app/bin
  • SHELL: /usr/local/bin/zsh
  • LANG: en_US.UTF-8
  • PWD: /Users/pradyunsg/Projects/csi-18/polling

Contents of Pipfile ('/Users/pradyunsg/Projects/csi-18/polling/Pipfile'):

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

[packages]
django = "*"

[dev-packages]

[requires]
python_version = "3.7"

Contents of Pipfile.lock ('/Users/pradyunsg/Projects/csi-18/polling/Pipfile.lock'):

{
    "_meta": {
        "hash": {
            "sha256": "627ef89f247ecee27e9ef0dabe116108d09c47abf171c900a8817befa64f9dd2"
        },
        "pipfile-spec": 6,
        "requires": {
            "python_version": "3.7"
        },
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.org/simple",
                "verify_ssl": true
            }
        ]
    },
    "default": {
        "django": {
            "hashes": [
                "sha256:04f2e423f2e60943c02bd2959174b844f7d1bcd19eabb7f8e4282999958021fd",
                "sha256:e1cc1cd6b658aa4e052f5f2b148bfda08091d7c3558529708342e37e4e33f72c"
            ],
            "index": "pypi",
            "version": "==2.1.1"
        },
        "pytz": {
            "hashes": [
                "sha256:a061aa0a9e06881eb8b3b2b43f05b9439d6583c206d0a6c340ff72a7b6669053",
                "sha256:ffb9ef1de172603304d9d2819af6f5ece76f2e85ec10692a524dd876e72bf277"
            ],
            "version": "==2018.5"
        }
    },
    "develop": {}
}

Most helpful comment

This is a workaround for locking the pip version to 18.0

pip install pipenv
pipenv run pip install pip==18.0
pipenv install

All 27 comments

Oh! The environment had an in-development version of pip. πŸ™ˆ

pip 18.1 was released several minutes ago and now pipenv doesn't work for me too, so I had to pin pip to 18.0 as a quick workaround.

This affected me too on Python 3.6.

Upgrading pip and pipenv brings them to 18.1 and 2018.7.1 and this combination results in TypeError related to _strip_extras.

This issue should be re-opened or duplicated. Update: see #2924.

I'm having a similar problem. I'm trying to create a new environment, using python 3.6

$ pipenv install pandas
Creating a Pipfile for this project...
Installing pandas...
Requirement already satisfied: pandas in /home/echo66/.local/share/virtualenvs/LDSSA-2ApiwGJI/lib/python3.6/site-packages (0.23.4)
Requirement already satisfied: pytz>=2011k in /home/echo66/.local/share/virtualenvs/LDSSA-2ApiwGJI/lib/python3.6/site-packages (from pandas) (2018.5)
Requirement already satisfied: numpy>=1.9.0 in /home/echo66/.local/share/virtualenvs/LDSSA-2ApiwGJI/lib/python3.6/site-packages (from pandas) (1.15.2)
Requirement already satisfied: python-dateutil>=2.5.0 in /home/echo66/.local/share/virtualenvs/LDSSA-2ApiwGJI/lib/python3.6/site-packages (from pandas) (2.7.3)
Requirement already satisfied: six>=1.5 in /home/echo66/.local/share/virtualenvs/LDSSA-2ApiwGJI/lib/python3.6/site-packages (from python-dateutil>=2.5.0->pandas) (1.11.0)

Adding pandas to Pipfile's [packages]...
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
kages/pipenv/utils.py", line 402, in resolve_deps
    req_dir=req_dir
  File "/home/echo66/.local/lib/python3.6/site-packages/pipenv/utils.py", line 250, in actually_resolve_deps
    req = Requirement.from_line(dep)
  File "/home/echo66/.local/lib/python3.6/site-packages/pipenv/vendor/requirementslib/models/requirements.py", line 704, in from_line
    line, extras = _strip_extras(line)
TypeError: 'module' object is not callable

The Pipfile has the following content

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

[packages]
pandas = "*"

[dev-packages]

[requires]
python_version = "3.6"

No Pipfile.lock was produced. But I'm able to use pipenv shell.

New issue created for this: #2924

This is a workaround for locking the pip version to 18.0

pip install pipenv
pipenv run pip install pip==18.0
pipenv install

This workaround doesn't work to me.

@joao-geru And do you want help? You'll need to give us more than that. What commands are you running? Output? Error messages? pipenv run pip --version

The above didn't quite work for me, what did was:

pip install pipenv==2018.6.25
pip install pip==18.0
pipenv install

Hi Williams,

I did update of pip and pipenv:

pip install --user -U --no-cache-dir pip pipenv

Collecting pip
  Downloading https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl (1.3MB)

    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 1.3MB 101.9MB/s 
Requirement already up-to-date: pipenv in /usr/local/lib/python3.6/site-packages (2018.7.1)
Requirement already satisfied, skipping upgrade: virtualenv-clone>=0.2.5 in /usr/local/lib/python3.6/site-packages (from pipenv) (0.3.0)
Requirement already satisfied, skipping upgrade: certifi in /usr/local/lib/python3.6/site-packages (from pipenv) (2018.8.24)
Requirement already satisfied, skipping upgrade: virtualenv in /usr/local/lib/python3.6/site-packages (from pipenv) (16.0.0)
Requirement already satisfied, skipping upgrade: setuptools>=36.2.1 in /usr/local/lib/python3.6/site-packages (from pipenv) (40.2.0)
Installing collected packages: pip
Successfully installed pip-18.1

So, I was to execute pipenv:

pipenv install --dev

Creating a virtualenv for this project...
Pipfile: /home/joao/project/Pipfile
Using /usr/local/bin/python3.6m (3.6.6) to create virtualenv...
Running virtualenv with interpreter /usr/local/bin/python3.6m
Using base prefix '/usr/local'
New python executable in /home/joao/.local/share/virtualenvs/project-zxI9dQ-Q/bin/python3.6m
Also creating executable in /home/joao/.local/share/virtualenvs/project-zxI9dQ-Q/bin/python
Installing setuptools, pip, wheel...done.
Setting project for project-zxI9dQ-Q to /home/joao/project

Virtualenv location: /home/joao/.local/share/virtualenvs/project-zxI9dQ-Q
Installing dependencies from Pipfile.lock (431696)...
Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/cli.py", line 435, in install
    selective_upgrade=selective_upgrade,
  File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 1943, in do_install
    pypi_mirror=pypi_mirror,
  File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 1322, in do_init
    pypi_mirror=pypi_mirror,
  File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 807, in do_install_dependencies
    pypi_mirror=pypi_mirror,
  File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 1375, in pip_install
    package_name.split('--hash')[0].split('--trusted-host')[0]
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/requirementslib/models/requirements.py", line 704, in from_line
    line, extras = _strip_extras(line)
TypeError: 'module' object is not callable
  🐍   β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰ 0/88 β€” 00:00:00

Exited with code 1

@joao-geru look at your pip install

Successfully installed pip-18.1

As stated, you need pip-18.0 not 18.1

For me i had to install not in the pipenv, i installed in my python specific version

python3.5 -m pip install pip=18.0
pipenv install

Affected also Pypy3 (python 3.5).
DOwngraded pip to 18.0 - all worked well.

(logged in into shell, than made: pip install pip==18.0)

Installing dependencies from Pipfile...
Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/pipenv/cli.py", line 435, in install
    selective_upgrade=selective_upgrade,
  File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 1943, in do_install
    pypi_mirror=pypi_mirror,
  File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 1322, in do_init
    pypi_mirror=pypi_mirror,
  File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 807, in do_install_dependencies
    pypi_mirror=pypi_mirror,
  File "/usr/local/lib/python3.7/site-packages/pipenv/core.py", line 1375, in pip_install
    package_name.split('--hash')[0].split('--trusted-host')[0]
  File "/usr/local/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/requirements.py", line 704, in from_line
    line, extras = _strip_extras(line)
TypeError: 'module' object is not callable

I'm having a similar problem
python 3.7
Ubuntu 18.4, Windows 10

# RUN pip install --upgrade pip
RUN pip install pip==18.0

It work fine for my docker

I'm having a simlar problem.

  • Windows10
  • conda 4.5.11
  • Python 3.7.0
  • pip 18.0
  • pipenv 2018.7.1
>pipenv install requests
Installing requests...
Requirement already satisfied: requests in c:\users\yuji3\.virtualenvs\myproject-sgdw-lry\lib\site-packages (2.19.1)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\users\yuji3\.virtualenvs\myproject-sgdw-lry\lib\site-packages (from requests) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\yuji3\.virtualenvs\myproject-sgdw-lry\lib\site-packages (from requests) (2018.8.24)
Requirement already satisfied: urllib3<1.24,>=1.21.1 in c:\users\yuji3\.virtualenvs\myproject-sgdw-lry\lib\site-packages (from requests) (1.23)
Requirement already satisfied: idna<2.8,>=2.5 in c:\users\yuji3\.virtualenvs\myproject-sgdw-lry\lib\site-packages (from requests) (2.7)

Adding requests to Pipfile's [packages]...
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
0\envs\visualization\lib\site-packages\pipenv\utils.py", line 402, in resolve_deps
    req_dir=req_dir
  File "c:\users\yuji3\anaconda3_5.2.0\envs\visualization\lib\site-packages\pipenv\utils.py", line 250, in actually_resolve_deps
    req = Requirement.from_line(dep)
  File "c:\users\yuji3\anaconda3_5.2.0\envs\visualization\lib\site-packages\pipenv\vendor\requirementslib\models\requirements.py", line 704, in from_line
    line, extras = _strip_extras(line)
TypeError: 'module' object is not callable

@yuji38kwmt make sure that pip is 18.0 in your virtualenv

Thanks for flagging this everyone!

Please refrain from commenting here and provide your comments over at #2924. The reason for the issue has been identified and the fix should be available in the near future with a new release of pipenv.

The above didn't quite work for me, what did was:

pip install pipenv==2018.6.25
pip install pip==18.0
pipenv install

This solution might not effect immediately that's why it would be great that exit and activate shell again. FYI.

For me this was fixed by moving to the most recent version of pipenv (pipenv, version 2018.10.9)

Ubuntu 16.04 LTS
Python 3.5
I rolled back to pip==9.0.3. Pipenv was still trying to use pip==18.0.1.

> pip install pip==9.0.3
> pip run pip install pip==9.0.3
> pipenv install #success

it works thanks!

This workaround works on Linux Mint 18.3 "Sylvia" (based on Ubuntu Xenial) with Python 3.7 installed from deadsnakes PPA:

pipenv shell
pip install pip==18.0
pipenv install

No need to change pipenv. That is, no need to run this command:
pip install pipenv==2018.6.25
I still have:
pipenv, version 2018.7.1

Just install pip in your virtual environment (not in your main OS). That is: activate your virtual environment with:
pipenv shell
before installing the wanted pip version.

for now pipenv run pip install pip==18.0

Seems to be fixed with #2924.
Upgrade pipenv and it works.

pip install pipenv -U
pipenv install

maybe this issue should be opened again

Yeah no, this is resolved. If you have a bug with the most recent release open an issue. Don’t post with 0 context saying we should reopen something.

Was this page helpful?
0 / 5 - 0 ratings