Repository: pypa/pipenv

Issue:
VersionConflict with importlib-metadata
### Issue description

I don't know why `importlib-metadata` dependency conflict recently occurred, but I installed the package in my new environment.

```
pkg_resources.VersionConflict: (importlib-metadata 3.1.0 (/home/kevin/.virtualenvs/python-guide-UQdmv-Su/lib/python3.7/site-packages), Requirement.parse('importlib-metadata<2,>=0.12; python_version < "3.8"'))
```

### Expected result

Pipenv Lock can be executed normally

### Actual result

```
(python-guide)  ✘ kevin@kevin  ~/workspaces/develop/doc/python-guide  pip list
Package    Version
---------- -------
packaging  20.7
pip        20.2.1
setuptools 49.2.1
wheel      0.34.2
(python-guide)  kevin@kevin  ~/workspaces/develop/doc/python-guide  pip --version
pip 20.2.1 from /home/kevin/.virtualenvs/python-guide-UQdmv-Su/lib/python3.7/site-packages/pip (python 3.7)
(python-guide)  kevin@kevin  ~/workspaces/develop/doc/python-guide  pipenv --version
pipenv, version 2020.11.15
(python-guide)  kevin@kevin  ~/workspaces/develop/doc/python-guide  pipenv install importlib-metadata --verbose
Installing importlib-metadata...
Installing package: importlib-metadata
Writing supplied requirement line to temporary file: 'importlib-metadata'
Installing 'importlib-metadata'
⠙ Installing importlib-metadata...$ ['/home/kevin/.virtualenvs/python-guide-UQdmv-Su/bin/pip', 'install', '--verbose', '--upgrade', '--exists-action=i', '-r', '/tmp/pipenv-lk4n0l4d-requirements/pipenv-z4guu5ff-requirement.txt', '-i', 'https://pypi.org/simple']
Using source directory: '/home/kevin/.virtualenvs/python-guide-UQdmv-Su/src'
Adding importlib-metadata to Pipfile's [packages]...
✔ Installation Succeeded 
Pipfile.lock (a65489) out of date, updating to (ac86d9)...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
⠇ Locking...
                          ROUND 1                           
✘ Locking Failed! 
Current constraints:
  importlib-metadata (from -r /tmp/pipenvjcxsskfprequirements/pipenv-i3uz_75a-constraints.txt (line 2))

Finding the best candidates:
  found candidate importlib-metadata==3.1.0 (constraint was <any>)

Finding secondary dependencies:
  importlib-metadata==3.1.0 requires zipp>=0.5

New dependencies found in this round:
  adding ['zipp', '>=0.5', '[]']
Removed dependencies in this round:
------------------------------------------------------------
Result of round 1: not stable

                          ROUND 2                           
Current constraints:
  importlib-metadata (from -r /tmp/pipenvjcxsskfprequirements/pipenv-i3uz_75a-constraints.txt (line 2))
  zipp>=0.5 (from importlib-metadata==3.1.0->-r /tmp/pipenvjcxsskfprequirements/pipenv-i3uz_75a-constraints.txt (line 2))

Finding the best candidates:
  found candidate importlib-metadata==3.1.0 (constraint was <any>)
  found candidate zipp==3.4.0 (constraint was >=0.5)

Finding secondary dependencies:
  importlib-metadata==3.1.0 requires zipp>=0.5
  zipp==3.4.0               requires -
------------------------------------------------------------
Result of round 2: stable, done

Generating hashes:
  importlib-metadata
  zipp
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/pipenv/resolver.py", line 764, in <module>
    main()
  File "/usr/local/lib/python3.7/dist-packages/pipenv/resolver.py", line 760, in main
    dev=parsed.dev)
  File "/usr/local/lib/python3.7/dist-packages/pipenv/resolver.py", line 741, in _main
    resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages, dev)
  File "/usr/local/lib/python3.7/dist-packages/pipenv/resolver.py", line 714, in resolve_packages
    results = clean_results(results, resolver, project, dev)
  File "/usr/local/lib/python3.7/dist-packages/pipenv/resolver.py", line 590, in clean_results
    reverse_deps = project.environment.reverse_dependencies()
  File "/usr/local/lib/python3.7/dist-packages/pipenv/project.py", line 376, in environment
    self._environment = self.get_environment(allow_global=allow_global)
  File "/usr/local/lib/python3.7/dist-packages/pipenv/project.py", line 366, in get_environment
    environment.extend_dists(pipenv_dist)
  File "/usr/local/lib/python3.7/dist-packages/pipenv/environment.py", line 127, in extend_dists
    extras = self.resolve_dist(dist, self.base_working_set)
  File "/usr/local/lib/python3.7/dist-packages/pipenv/environment.py", line 122, in resolve_dist
    deps |= cls.resolve_dist(dist, working_set)
  File "/usr/local/lib/python3.7/dist-packages/pipenv/environment.py", line 121, in resolve_dist
    dist = working_set.find(req)
  File "/home/kevin/.virtualenvs/python-guide-UQdmv-Su/lib/python3.7/site-packages/pkg_resources/__init__.py", line 642, in find
    raise VersionConflict(dist, req)
pkg_resources.VersionConflict: (importlib-metadata 3.1.0 (/home/kevin/.virtualenvs/python-guide-UQdmv-Su/lib/python3.7/site-packages), Requirement.parse('importlib-metadata<2,>=0.12; python_version < "3.8"'))
ROUND 1                           
Current constraints:
  importlib-metadata (from -r /tmp/pipenvjcxsskfprequirements/pipenv-i3uz_75a-constraints.txt (line 2))

Finding the best candidates:
  found candidate importlib-metadata==3.1.0 (constraint was <any>)

Finding secondary dependencies:
  importlib-metadata==3.1.0 requires zipp>=0.5

New dependencies found in this round:
  adding ['zipp', '>=0.5', '[]']
Removed dependencies in this round:
------------------------------------------------------------
Result of round 1: not stable

                          ROUND 2                           
Current constraints:
  importlib-metadata (from -r /tmp/pipenvjcxsskfprequirements/pipenv-i3uz_75a-constraints.txt (line 2))
  zipp>=0.5 (from importlib-metadata==3.1.0->-r /tmp/pipenvjcxsskfprequirements/pipenv-i3uz_75a-constraints.txt (line 2))

Finding the best candidates:
  found candidate importlib-metadata==3.1.0 (constraint was <any>)
  found candidate zipp==3.4.0 (constraint was >=0.5)

Finding secondary dependencies:
  importlib-metadata==3.1.0 requires zipp>=0.5
  zipp==3.4.0               requires -
------------------------------------------------------------
Result of round 2: stable, done

Generating hashes:
  importlib-metadata
  zipp
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/pipenv/resolver.py", line 764, in <module>
    main()
  File "/usr/local/lib/python3.7/dist-packages/pipenv/resolver.py", line 760, in main
    dev=parsed.dev)
  File "/usr/local/lib/python3.7/dist-packages/pipenv/resolver.py", line 741, in _main
    resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages, dev)
  File "/usr/local/lib/python3.7/dist-packages/pipenv/resolver.py", line 714, in resolve_packages
    results = clean_results(results, resolver, project, dev)
  File "/usr/local/lib/python3.7/dist-packages/pipenv/resolver.py", line 590, in clean_results
    reverse_deps = project.environment.reverse_dependencies()
  File "/usr/local/lib/python3.7/dist-packages/pipenv/project.py", line 376, in environment
    self._environment = self.get_environment(allow_global=allow_global)
  File "/usr/local/lib/python3.7/dist-packages/pipenv/project.py", line 366, in get_environment
    environment.extend_dists(pipenv_dist)
  File "/usr/local/lib/python3.7/dist-packages/pipenv/environment.py", line 127, in extend_dists
    extras = self.resolve_dist(dist, self.base_working_set)
  File "/usr/local/lib/python3.7/dist-packages/pipenv/environment.py", line 122, in resolve_dist
    deps |= cls.resolve_dist(dist, working_set)
  File "/usr/local/lib/python3.7/dist-packages/pipenv/environment.py", line 121, in resolve_dist
    dist = working_set.find(req)
  File "/home/kevin/.virtualenvs/python-guide-UQdmv-Su/lib/python3.7/site-packages/pkg_resources/__init__.py", line 642, in find
    raise VersionConflict(dist, req)
pkg_resources.VersionConflict: (importlib-metadata 3.1.0 (/home/kevin/.virtualenvs/python-guide-UQdmv-Su/lib/python3.7/site-packages), Requirement.parse('importlib-metadata<2,>=0.12; python_version < "3.8"'))
```

### Steps to replicate

**command**

```cmd
pipenv install importlib-metadata --verbose
```

**Pipfile**

```toml
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
importlib-metadata = "*"

[requires]
python_version = "3.7"

```
-------------------------------------------------------------------------------

<details><summary>$ pipenv --support</summary>

Pipenv version: `'2020.11.15'`

Pipenv location: `'/usr/local/lib/python3.7/dist-packages/pipenv'`

Python location: `'/usr/bin/python3'`

Python installations found:

  - `3.7.3`: `/home/kevin/.virtualenvs/python-guide-UQdmv-Su/bin/python3`
  - `3.7.3`: `/home/kevin/.virtualenvs/python-guide-UQdmv-Su/bin/python3.7`
  - `3.7.3`: `/home/kevin/.virtualenvs/python-guide-UQdmv-Su/bin/python3.7m`
  - `3.7.3`: `/home/kevin/.virtualenvs/python-guide-UQdmv-Su/bin/python3`
  - `3.7.3`: `/home/kevin/.virtualenvs/python-guide-UQdmv-Su/bin/python3.7`
  - `3.7.3`: `/home/kevin/.virtualenvs/python-guide-UQdmv-Su/bin/python3.7m`
  - `3.7.3`: `/usr/local/bin/python3.7m`
  - `3.7.3`: `/usr/local/bin/python3.7`
  - `3.7.3`: `/usr/bin/python3.7m`
  - `3.7.3`: `/usr/bin/python3`
  - `3.7.3`: `/usr/bin/python3.7`
  - `3.7.3`: `/bin/python3.7m`
  - `3.7.3`: `/bin/python3`
  - `3.7.3`: `/bin/python3.7`
  - `3.6.8`: `/usr/local/bin/python3.6m`
  - `3.6.8`: `/usr/local/bin/python3.6`
  - `3.6.8`: `/usr/bin/python3.6`
  - `3.6.8`: `/bin/python3.6`
  - `3.5.3`: `/usr/bin/python3.5`
  - `3.5.3`: `/usr/bin/python3.5m`
  - `3.5.3`: `/bin/python3.5`
  - `3.5.3`: `/bin/python3.5m`
  - `2.7.16`: `/usr/bin/python2`
  - `2.7.16`: `/usr/bin/python2.7`
  - `2.7.16`: `/bin/python2`
  - `2.7.16`: `/bin/python2.7`

PEP 508 Information:

```
{'implementation_name': 'cpython',
 'implementation_version': '3.7.3',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '5.4.70-amd64-desktop',
 'platform_system': 'Linux',
 'platform_version': '#1 SMP Wed Oct 14 15:24:23 CST 2020',
 'python_full_version': '3.7.3',
 'python_version': '3.7',
 'sys_platform': 'linux'}
```

System environment variables:

  - `USER`
  - `LANGUAGE`
  - `WORKON_HOME`
  - `XDG_SEAT`
  - `SBT_HOME`
  - `POSTGRESQL_HOME`
  - `XDG_SESSION_TYPE`
  - `XDG_CACHE_HOME`
  - `LD_LIBRARY_PATH`
  - `HOME`
  - `VIRTUALENVWRAPPER_PYTHON`
  - `QT4_IM_MODULE`
  - `DESKTOP_SESSION`
  - `GIO_LAUNCHED_DESKTOP_FILE`
  - `XDG_SEAT_PATH`
  - `GRADLE_HOME`
  - `SCALA_HOME`
  - `CATALINA_HOME`
  - `QT_LINUX_ACCESSIBILITY_ALWAYS_ON`
  - `QT_DBL_CLICK_DIST`
  - `HADOOP_COMMON_LIB_NATIVE_DIR`
  - `DBUS_SESSION_BUS_ADDRESS`
  - `GIO_LAUNCHED_DESKTOP_FILE_PID`
  - `LOGNAME`
  - `GTK_IM_MODULE`
  - `XDG_SESSION_CLASS`
  - `XDG_SESSION_ID`
  - `GNOME_DESKTOP_SESSION_ID`
  - `PATH`
  - `XDG_SESSION_PATH`
  - `XDG_RUNTIME_DIR`
  - `DISPLAY`
  - `CMAKE_HOME`
  - `LANG`
  - `XDG_CURRENT_DESKTOP`
  - `XDG_SESSION_DESKTOP`
  - `XAUTHORITY`
  - `XDG_DATA_HOME`
  - `XDG_CONFIG_HOME`
  - `XMODIFIERS`
  - `XDG_GREETER_DATA_DIR`
  - `SSH_AUTH_SOCK`
  - `SHELL`
  - `NODE_PATH`
  - `GDMSESSION`
  - `QT_ACCESSIBILITY`
  - `QT_LOGGING_RULES`
  - `CLASSPATH`
  - `GPG_AGENT_INFO`
  - `XDG_VTNR`
  - `QT_IM_MODULE`
  - `PWD`
  - `JAVA_HOME`
  - `GRADLE_USER_HOME`
  - `XDG_DATA_DIRS`
  - `CLUTTER_IM_MODULE`
  - `M2_HOME`
  - `HADOOP_HOME`
  - `CHROME_DESKTOP`
  - `ORIGINAL_XDG_CURRENT_DESKTOP`
  - `VIRTUALENVWRAPPER_WORKON_CD`
  - `XCURSOR_SIZE`
  - `SHLVL`
  - `OLDPWD`
  - `LESS`
  - `D_DISABLE_RT_SCREEN_SCALE`
  - `ZSH`
  - `LSCOLORS`
  - `PAGER`
  - `COLORTERM`
  - `WINDOWID`
  - `_`
  - `COLORFGBG`
  - `TERM`
  - `QT_SCALE_FACTOR_ROUNDING_POLICY`
  - `VIRTUALENVWRAPPER_PROJECT_FILENAME`
  - `VIRTUALENVWRAPPER_HOOK_DIR`
  - `VIRTUALENVWRAPPER_SCRIPT`
  - `APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL`
  - `NO_AT_BRIDGE`
  - `TERM_PROGRAM`
  - `TERM_PROGRAM_VERSION`
  - `VSCODE_GIT_IPC_HANDLE`
  - `GIT_ASKPASS`
  - `VSCODE_GIT_ASKPASS_NODE`
  - `VSCODE_GIT_ASKPASS_MAIN`
  - `LS_COLORS`
  - `PIP_DISABLE_PIP_VERSION_CHECK`
  - `PYTHONDONTWRITEBYTECODE`
  - `PIP_PYTHON_PATH`
  - `PIPENV_ACTIVE`
  - `VIRTUAL_ENV`
  - `PS1`
  - `PIP_SHIMS_BASE_MODULE`
  - `PYTHONFINDER_IGNORE_UNSUPPORTED`

Pipenv–specific environment variables:

 - `PIPENV_ACTIVE`: `1`

Debug–specific environment variables:

  - `PATH`: `/home/kevin/.virtualenvs/python-guide-UQdmv-Su/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/sbin:/usr/sbin:/snap/bin:/opt/softwares/jdk1.8.0_141/bin:/opt/softwares/maven-3.6.1/bin:/opt/softwares/gradle-5.4.1/bin:/opt/softwares/sbt/bin:/opt/softwares/scala/bin:/opt/softwares/node-v12.3.1/bin:/data/repository/nodejs/node_global/bin:/opt/softwares/tomcat-9.0.30/bin:/usr/hdp/3.1.0.0-78/hadoop/bin:/usr/hdp/3.1.0.0-78/hadoop/sbin:/usr/local/pgsql/bin/:/opt/softwares/cmake/bin`
  - `SHELL`: `/usr/bin/zsh`
  - `LANG`: `zh_CN.UTF-8`
  - `PWD`: `/home/kevin/workspaces/develop/doc/python-guide`
  - `VIRTUAL_ENV`: `/home/kevin/.virtualenvs/python-guide-UQdmv-Su`


---------------------------

Contents of `Pipfile` ('/home/kevin/workspaces/develop/doc/python-guide/Pipfile'):

```toml
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
importlib-metadata = "*"

[requires]
python_version = "3.7"

```


Contents of `Pipfile.lock` ('/home/kevin/workspaces/develop/doc/python-guide/Pipfile.lock'):

```json
{
    "_meta": {
        "hash": {
            "sha256": "7e7ef69da7248742e869378f8421880cf8f0017f96d94d086813baa518a65489"
        },
        "pipfile-spec": 6,
        "requires": {
            "python_version": "3.7"
        },
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.org/simple",
                "verify_ssl": true
            }
        ]
    },
    "default": {},
    "develop": {}
}

```
</details>

---

I'm sorry to interrupt your normal work. I would appreciate it if you could help me.
Any package requiring importlib-metadata breaks locking
The most recent version of `importlib-metadata` is 2.0.0.  This is the version that gets resolved when any package is installed that required `importlib-metadata` without an upper bound. For example: `flake8`.

The `virtualenv` library requires `importlib-metadata < 2.0`.

When `project.get_environment()` is called the dependencies for `virtualenv` are compared to the working set resolved for the Pipfile dependencies and a VersonConflict error is raised.

This is a very frustrating error because doing `pipenv lock -v` gives no indication of which package requires importlib-metadata < 2.0. Also inspecting `pipenv graph` gives no indication either.

A temporary fix would be to pin `importlib-metadata == "1.7.0"` in the Pipfile.


Discussion:
I'm having this issue too and can confirm it happens with only `importlib-metadata` in the `Pipfile`.

<details><summary>pipenv install -v importlib-metadata</summary>

```
Using python: 3.6
Path to python: /usr/bin/python3.6m
Creating a virtualenv for this project...
Pipfile: /home/kususer/Documents/pl/Pipfile
Using /usr/bin/python3.6m (3.6.8) to create virtualenv...
created virtual environment CPython3.6.8.final.0-64 in 197ms
  creator CPython3Posix(dest=/home/kususer/.local/share/virtualenvs/pl-E9dLybHL, clear=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/kususer/.local/share/virtualenv)
    added seed packages: pip==20.3.3, setuptools==51.0.0, wheel==0.36.2
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

✔ Successfully created virtual environment!
Virtualenv location: /home/kususer/.local/share/virtualenvs/pl-E9dLybHL
Installing importlib-metadata...
Installing package: importlib-metadata
Writing supplied requirement line to temporary file: 'importlib-metadata'
Installing 'importlib-metadata'
$ ['/home/kususer/.local/share/virtualenvs/pl-E9dLybHL/bin/pip', 'install', '--verbose', '--upgrade', '--exists-action=i', '-r', '/tmp/pipenv-bmtsiouc-requirements/pipenv-wft51l29-requirement.txt', '-i', 'https://pypi.org/simple']
Using source directory: '/home/kususer/.local/share/virtualenvs/pl-E9dLybHL/src'
Adding importlib-metadata to Pipfile's [packages]...
✔ Installation Succeeded
Pipfile.lock (ca72e7) out of date, updating to (640804)...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...

FAIL
                          ROUND 1                           
Current constraints:
  importlib-metadata (from -r /tmp/pipenvy9j0bwonrequirements/pipenv-zf3gehs3-constraints.txt (line 2))

Finding the best candidates:
  found candidate importlib-metadata==3.4.0 (constraint was <any>)

Finding secondary dependencies:
  importlib-metadata==3.4.0 requires typing-extensions>=3.6.4; python_version < "3.8", zipp>=0.5

New dependencies found in this round:
  adding ['typing-extensions', '>=3.6.4', '[]']
  adding ['zipp', '>=0.5', '[]']
Removed dependencies in this round:
------------------------------------------------------------
Result of round 1: not stable

                          ROUND 2                           
Current constraints:
  importlib-metadata (from -r /tmp/pipenvy9j0bwonrequirements/pipenv-zf3gehs3-constraints.txt (line 2))
  typing-extensions>=3.6.4 (from importlib-metadata==3.4.0->-r /tmp/pipenvy9j0bwonrequirements/pipenv-zf3gehs3-constraints.txt (line 2))
  zipp>=0.5 (from importlib-metadata==3.4.0->-r /tmp/pipenvy9j0bwonrequirements/pipenv-zf3gehs3-constraints.txt (line 2))

Finding the best candidates:
  found candidate importlib-metadata==3.4.0 (constraint was <any>)
  found candidate typing-extensions==3.7.4.3 (constraint was >=3.6.4)
  found candidate zipp==3.4.0 (constraint was >=0.5)

Finding secondary dependencies:
  zipp==3.4.0               requires -
  importlib-metadata==3.4.0 requires typing-extensions>=3.6.4; python_version < "3.8", zipp>=0.5
  typing-extensions==3.7.4.3 requires -
------------------------------------------------------------
Result of round 2: stable, done

Generating hashes:
  zipp
  importlib-metadata
  typing-extensions
Traceback (most recent call last):
  File "/home/kususer/.local/pipx/venvs/pipenv/lib64/python3.6/site-packages/pipenv/resolver.py", line 764, in <module>
    main()
  File "/home/kususer/.local/pipx/venvs/pipenv/lib64/python3.6/site-packages/pipenv/resolver.py", line 760, in main
    dev=parsed.dev)
  File "/home/kususer/.local/pipx/venvs/pipenv/lib64/python3.6/site-packages/pipenv/resolver.py", line 741, in _main
    resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages, dev)
  File "/home/kususer/.local/pipx/venvs/pipenv/lib64/python3.6/site-packages/pipenv/resolver.py", line 714, in resolve_packages
    results = clean_results(results, resolver, project, dev)
  File "/home/kususer/.local/pipx/venvs/pipenv/lib64/python3.6/site-packages/pipenv/resolver.py", line 590, in clean_results
    reverse_deps = project.environment.reverse_dependencies()
  File "/home/kususer/.local/pipx/venvs/pipenv/lib/python3.6/site-packages/pipenv/project.py", line 376, in environment
    self._environment = self.get_environment(allow_global=allow_global)
  File "/home/kususer/.local/pipx/venvs/pipenv/lib/python3.6/site-packages/pipenv/project.py", line 366, in get_environment
    environment.extend_dists(pipenv_dist)
  File "/home/kususer/.local/pipx/venvs/pipenv/lib/python3.6/site-packages/pipenv/environment.py", line 127, in extend_dists
    extras = self.resolve_dist(dist, self.base_working_set)
  File "/home/kususer/.local/pipx/venvs/pipenv/lib/python3.6/site-packages/pipenv/environment.py", line 122, in resolve_dist
    deps |= cls.resolve_dist(dist, working_set)
  File "/home/kususer/.local/pipx/venvs/pipenv/lib/python3.6/site-packages/pipenv/environment.py", line 121, in resolve_dist
    dist = working_set.find(req)
  File "/home/kususer/.local/share/virtualenvs/pl-E9dLybHL/lib/python3.6/site-packages/pkg_resources/__init__.py", line 627, in find
    raise VersionConflict(dist, req)
pkg_resources.VersionConflict: (importlib-metadata 3.4.0 (/home/kususer/.local/share/virtualenvs/pl-E9dLybHL/lib/python3.6/site-packages), Requirement.parse('importlib-metadata<3,>=0.12; python_version < "3.8"'))
ROUND 1                           
Current constraints:
  importlib-metadata (from -r /tmp/pipenvy9j0bwonrequirements/pipenv-zf3gehs3-constraints.txt (line 2))

Finding the best candidates:
  found candidate importlib-metadata==3.4.0 (constraint was <any>)

Finding secondary dependencies:
  importlib-metadata==3.4.0 requires typing-extensions>=3.6.4; python_version < "3.8", zipp>=0.5

New dependencies found in this round:
  adding ['typing-extensions', '>=3.6.4', '[]']
  adding ['zipp', '>=0.5', '[]']
Removed dependencies in this round:
------------------------------------------------------------
Result of round 1: not stable

                          ROUND 2                           
Current constraints:
  importlib-metadata (from -r /tmp/pipenvy9j0bwonrequirements/pipenv-zf3gehs3-constraints.txt (line 2))
  typing-extensions>=3.6.4 (from importlib-metadata==3.4.0->-r /tmp/pipenvy9j0bwonrequirements/pipenv-zf3gehs3-constraints.txt (line 2))
  zipp>=0.5 (from importlib-metadata==3.4.0->-r /tmp/pipenvy9j0bwonrequirements/pipenv-zf3gehs3-constraints.txt (line 2))

Finding the best candidates:
  found candidate importlib-metadata==3.4.0 (constraint was <any>)
  found candidate typing-extensions==3.7.4.3 (constraint was >=3.6.4)
  found candidate zipp==3.4.0 (constraint was >=0.5)

Finding secondary dependencies:
  zipp==3.4.0               requires -
  importlib-metadata==3.4.0 requires typing-extensions>=3.6.4; python_version < "3.8", zipp>=0.5
  typing-extensions==3.7.4.3 requires -
------------------------------------------------------------
Result of round 2: stable, done

Generating hashes:
  zipp
  importlib-metadata
  typing-extensions
Traceback (most recent call last):
  File "/home/kususer/.local/pipx/venvs/pipenv/lib64/python3.6/site-packages/pipenv/resolver.py", line 764, in <module>
    main()
  File "/home/kususer/.local/pipx/venvs/pipenv/lib64/python3.6/site-packages/pipenv/resolver.py", line 760, in main
    dev=parsed.dev)
  File "/home/kususer/.local/pipx/venvs/pipenv/lib64/python3.6/site-packages/pipenv/resolver.py", line 741, in _main
    resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages, dev)
  File "/home/kususer/.local/pipx/venvs/pipenv/lib64/python3.6/site-packages/pipenv/resolver.py", line 714, in resolve_packages
    results = clean_results(results, resolver, project, dev)
  File "/home/kususer/.local/pipx/venvs/pipenv/lib64/python3.6/site-packages/pipenv/resolver.py", line 590, in clean_results
    reverse_deps = project.environment.reverse_dependencies()
  File "/home/kususer/.local/pipx/venvs/pipenv/lib/python3.6/site-packages/pipenv/project.py", line 376, in environment
    self._environment = self.get_environment(allow_global=allow_global)
  File "/home/kususer/.local/pipx/venvs/pipenv/lib/python3.6/site-packages/pipenv/project.py", line 366, in get_environment
    environment.extend_dists(pipenv_dist)
  File "/home/kususer/.local/pipx/venvs/pipenv/lib/python3.6/site-packages/pipenv/environment.py", line 127, in extend_dists
    extras = self.resolve_dist(dist, self.base_working_set)
  File "/home/kususer/.local/pipx/venvs/pipenv/lib/python3.6/site-packages/pipenv/environment.py", line 122, in resolve_dist
    deps |= cls.resolve_dist(dist, working_set)
  File "/home/kususer/.local/pipx/venvs/pipenv/lib/python3.6/site-packages/pipenv/environment.py", line 121, in resolve_dist
    dist = working_set.find(req)
  File "/home/kususer/.local/share/virtualenvs/pl-E9dLybHL/lib/python3.6/site-packages/pkg_resources/__init__.py", line 627, in find
    raise VersionConflict(dist, req)
pkg_resources.VersionConflict: (importlib-metadata 3.4.0 (/home/kususer/.local/share/virtualenvs/pl-E9dLybHL/lib/python3.6/site-packages), Requirement.parse('importlib-metadata<3,>=0.12; python_version < "3.8"'))
Traceback (most recent call last):
  File "/home/kususer/.local/pipx/venvs/pipenv/lib64/python3.6/site-packages/pipenv/utils.py", line 1131, in create_spinner
    yield sp
  File "/home/kususer/.local/pipx/venvs/pipenv/lib64/python3.6/site-packages/pipenv/utils.py", line 1338, in venv_resolve_deps
    c = resolve(cmd, sp)
  File "/home/kususer/.local/pipx/venvs/pipenv/lib64/python3.6/site-packages/pipenv/utils.py", line 1176, in resolve
    sys.exit(c.return_code)
SystemExit: 1
```

</details>
I'm encountering this too. A bit more information: this seems to happen when the upper bound is only set in the `dev-packages` section.

In the case of this Pipfile `importlib-metadata` gets locked to version `2.0.0`:
```
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
virtualenv = "==20.0.31"

[packages]
flake8 = "==3.8.3"

[requires]
python_version = "3.6"
```

However, with this file, `importlib-metadata` gets properly locked to version `1.7.0`:
```
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
virtualenv = "==20.0.31"
flake8 = "==3.8.3"

[requires]
python_version = "3.6"
```
Here are my debugging notes. Still not sure which package is causing the problem, but this does seem to fix it.

The error you get when you first run `pipenv install` with pipenv version `2020.8.13`.

```
Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1259, 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 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/cli/command.py", line 252, in install
    site_packages=state.site_packages
  File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 1928, in do_install
    site_packages=site_packages,
  File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 580, in ensure_project
    pypi_mirror=pypi_mirror,
  File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 512, in ensure_virtualenv
    python=python, site_packages=site_packages, pypi_mirror=pypi_mirror
  File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 999, in do_create_virtualenv
    project._environment.add_dist("pipenv")
  File "/usr/local/lib/python3.6/site-packages/pipenv/environment.py", line 135, in add_dist
    self.extend_dists(dist)
  File "/usr/local/lib/python3.6/site-packages/pipenv/environment.py", line 127, in extend_dists
    extras = self.resolve_dist(dist, self.base_working_set)
  File "/usr/local/lib/python3.6/site-packages/pipenv/environment.py", line 122, in resolve_dist
    deps |= cls.resolve_dist(dist, working_set)
  File "/usr/local/lib/python3.6/site-packages/pipenv/environment.py", line 121, in resolve_dist
    dist = working_set.find(req)
  File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 642, in find
    raise VersionConflict(dist, req)
pkg_resources.VersionConflict: (importlib-metadata 2.0.0 (/usr/local/lib/python3.6/site-packages), Requirement.parse('importlib-metadata<2,>=0.12; python_version < "3.8"'))
```

If you run `pip install -U pipenv` it seems to change the `importlib-metadata` version:

```
Installing collected packages: importlib-metadata
  Attempting uninstall: importlib-metadata
    Found existing installation: importlib-metadata 2.0.0
    Uninstalling importlib-metadata-2.0.0:
      Successfully uninstalled importlib-metadata-2.0.0
Successfully installed importlib-metadata-1.7.0
```

Now if you run `pipenv install -d --skip-lock` it will finish. It seems like a library is requiring a version `>= importlib-metadata 2.0`.

When I pinned the following dependencies it didn't work at first when running `pipenv lock`, however, if I removed the lock file (`rm Pipenv.lock`) then it worked when I ran `pipenv lock` again.

```
virtualenv = "==20.0.31"
importlib-metadata = "==1.7.0"
```

The sequence of calls causing this error are fairly elaborate.
1. Call pipenv lock
2. This results in a call to main in resolver.py within a subprocess
3. This causes a call to clean_results **only if there is an already existing lock file**
4. This results in an attempt to instantiate the project environment to find reverse dependencies.
5. When instantiating the project environment the pipenv distribution is added to the environment using extend_dists
6. In extend_dists a search is conducted for all dependencies of pipenv in the working set
7. This results in a search for package versions matching the requirements of virtualenv including importlib-metadata

If this search results in finding no version of the package installed, then there is no error.

However, if there is only a version of the package that conflicts with virtualenv's requirements installed then the error discussed above is thrown.

So to see this specific error you would likely need to fall under the following conditions:

- Use importlib-metadata in your project (directly or as a dependency)
- Use a version of python in your project for which virtualenv requires importlib-metadata <2 (e.g. 3.7)
- Not have importlib-metadata 1.7 or earlier installed elsewhere so that there is a non-conflicting version of the package in the working set.

Without fully understanding the logic of adding pipenv to the project environment, it is hard to know the right point at which to address this issue.

However, it would seem that the dependency check for pipenv should use the version of python which will be used to run pipenv. Then an error would reflect a real problem, rather than the current situation.

Alternatively, error handling around adding pipenv to the environment  could handle VersionConflict errors. Either silently, which would assume that pipenv was correctly installed with its dependencies, but that might obviate the point of adding it to the environment. Or perhaps by installing required dependencies for pipenv for the project version of python.

With `pip install -U pipenv` was solved for me.

@nicofuchsg if you're implying that simply running the latest version of `pipenv` solves the problem, fyi that's not the case universally.

I encountered this issue using `pipenv 2020.8.13` from start to finish.
If people go back and look at my notes it confirms that simply running `pip install -U pipenv` did not work for me.

cc: @nicofuchsg 
`pip uninstall -y importlib-metadata` and run `pipenv lock` again work for me.
@DriverX, that doesn't work for me, unfortunately. The only thing that works is what I documented above.
I found that my issue was actually just matter of updating to the newest `virtualenv` patch release `20.0.32`

- https://virtualenv.pypa.io/en/stable/changelog.html#v20-0-32-2020-10-01
- https://github.com/pypa/virtualenv/pull/1953

once that version was released and incorporated into my lockfiles everything worked like a charm on both python 3.7 and 3.8.
The workaround of deleting the `Pipfile.lock` file and then re-running `pipenv lock` always seems to work but here is what I did for a more permanent fix.

1. Destroy local pipenv virtualenv `pipenv --rm`
2. Uninstall pipenv `brew uninstall pipenv`
3. Upgrade virtualenv `pip install -U virtualenv`
4. Reinstall pipenv `pip install --user pipenv`
5. Recreate pipenv virtualenv `pipenv install`

Repeat runs of `pipenv lock` work as expected and do not re-trigger the conflict error message.
@scuerda, worked like a charm, thank you!
This issue is fixed by the newest release of `virtualenv`

Any newcomers to this issue should upgrade the version of `virtualenv`
How about if we are using pip instead of virtualenv.
With `importlib-metadata` 3.0.0 this error seems to be occurring again, even after having the latest version of virtualenv
```
⠹ Locking..✘ Locking Failed! 
Traceback (most recent call last):
  File "/home/user/.local/share/virtualenvs/user-5PivF_Od/lib/python3.6/site-packages/pipenv/resolver.py", line 764, in <module>
    main()
  File "/home/user/.local/share/virtualenvs/user-5PivF_Od/lib/python3.6/site-packages/pipenv/resolver.py", line 760, in main
    dev=parsed.dev)
  File "/home/user/.local/share/virtualenvs/user-5PivF_Od/lib/python3.6/site-packages/pipenv/resolver.py", line 741, in _main
    resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages, dev)
  File "/home/user/.local/share/virtualenvs/user-5PivF_Od/lib/python3.6/site-packages/pipenv/resolver.py", line 714, in resolve_packages
    results = clean_results(results, resolver, project, dev)
  File "/home/user/.local/share/virtualenvs/user-5PivF_Od/lib/python3.6/site-packages/pipenv/resolver.py", line 590, in clean_results
    reverse_deps = project.environment.reverse_dependencies()
  File "/home/user/.local/share/virtualenvs/user-5PivF_Od/lib/python3.6/site-packages/pipenv/project.py", line 376, in environment
    self._environment = self.get_environment(allow_global=allow_global)
  File "/home/user/.local/share/virtualenvs/user-5PivF_Od/lib/python3.6/site-packages/pipenv/project.py", line 366, in get_environment
    environment.extend_dists(pipenv_dist)
  File "/home/user/.local/share/virtualenvs/user-5PivF_Od/lib/python3.6/site-packages/pipenv/environment.py", line 127, in extend_dists
    extras = self.resolve_dist(dist, self.base_working_set)
  File "/home/user/.local/share/virtualenvs/user-5PivF_Od/lib/python3.6/site-packages/pipenv/environment.py", line 122, in resolve_dist
    deps |= cls.resolve_dist(dist, working_set)
  File "/home/user/.local/share/virtualenvs/user-5PivF_Od/lib/python3.6/site-packages/pipenv/environment.py", line 121, in resolve_dist
    dist = working_set.find(req)
  File "/tmp/tmppbnfl0ad/.venv/lib/python3.6/site-packages/pkg_resources/__init__.py", line 627, in find
    raise VersionConflict(dist, req)
pkg_resources.VersionConflict: (importlib-metadata 3.0.0 (/tmp/tmppbnfl0ad/.venv/lib/python3.6/site-packages), Requirement.parse('importlib-metadata<3,>=0.12; python_version < "3.8"'))
```
Any suggestions on what we could do to avoid this?
@joshsleeper
I only ran into this issue when I was using a pyenv miniconda version for my pipenv's python. No issues when I use a standard 3.8 pyenv installation.
Following @scuerda comment it works for me to fix `importlib-metadata 3.0.0` with last pipenv version, hope it helps  
> The workaround of deleting the `Pipfile.lock` file and then re-running `pipenv lock` always seems to work but here is what I did for a more permanent fix.
> 
> 1. Destroy local pipenv virtualenv `pipenv --rm`
> 2. Uninstall pipenv `brew uninstall pipenv`
> 3. Upgrade virtualenv `pip install -U virtualenv`
> 4. Reinstall pipenv `pip install --user pipenv`
> 5. Recreate pipenv virtualenv `pipenv install`
> 
> Repeat runs of `pipenv lock` work as expected and do not re-trigger the conflict error message.


I'm still having this issue trying to install tensorflow 1.15 with pip on OS X into a conda environment. I install a previous version of `importlib-metadata` however one of the dependencies in the tensorflow package is forcing the newer version of `importlib-metadata`:

`Installing collected packages: zipp, six, numpy, importlib-metadata, cached-property, wheel, werkzeug, setuptools, protobuf, markdown, h5py, grpcio, absl-py, wrapt, termcolor, tensorflow-estimator, tensorboard, opt-einsum, keras-preprocessing, keras-applications, google-pasta, gast, astor, tensorflow`

`ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
virtualenv 20.0.31 requires importlib-metadata<2,>=0.12; python_version < "3.8", but you have importlib-metadata 3.1.1 which is incompatible.`

**EDIT:** I've managed to install tensorflow 1.15 using conda.
I wonder if there are plans for the `pipenv` to use the new built-in `pip` dependency resolver.

Resolving patch:
diff --git a/pipenv/environment.py b/pipenv/environment.py
--- a/pipenv/environment.py
+++ b/pipenv/environment.py
@@ -118,7 +118,12 @@ def resolve_dist(cls, dist, working_set):
         except (KeyError, AttributeError, OSError, IOError):  # The METADATA file can't be found
             return deps
         for req in reqs:
-            dist = working_set.find(req)
+            try:
+                dist = working_set.find(req)
+            except pkg_resources.VersionConflict:
+                # https://github.com/pypa/pipenv/issues/4549
+                # The requirement is already present with incompatible version.
+                continue
             deps |= cls.resolve_dist(dist, working_set)
         return deps
 
diff --git a/pipenv/resolver.py b/pipenv/resolver.py
--- a/pipenv/resolver.py
+++ b/pipenv/resolver.py
@@ -12,7 +12,7 @@
 
 def find_site_path(pkg, site_dir=None):
     import pkg_resources
-    if site_dir is not None:
+    if site_dir is None:
         site_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
     working_set = pkg_resources.WorkingSet([site_dir] + sys.path[:])
     for dist in working_set:
diff --git a/tasks/vendoring/__init__.py b/tasks/vendoring/__init__.py
--- a/tasks/vendoring/__init__.py
+++ b/tasks/vendoring/__init__.py
@@ -6,6 +6,7 @@
 import io
 import itertools
 import json
+import os
 import re
 import shutil
 
@@ -21,7 +22,7 @@
 
 from urllib3.util import parse_url as urllib3_parse
 
-from pipenv.vendor.vistir.compat import NamedTemporaryFile, TemporaryDirectory
+from pipenv.vendor.vistir.compat import TemporaryDirectory
 from pipenv.vendor.vistir.contextmanagers import open_file
 from pipenv.vendor.requirementslib.models.lockfile import Lockfile, merge_items
 import pipenv.vendor.parse as parse
@@ -205,14 +206,10 @@ def _recursive_write_to_zip(zf, path, root=None):
 
 @invoke.task
 def update_safety(ctx):
-    ignore_subdeps = ["pip", "pip-egg-info", "bin", "pipenv", "virtualenv", "virtualenv-clone", "setuptools",]
+    ignore_subdeps = ["pip", "pip-egg-info", "bin", "pipenv", "virtualenv", "virtualenv-clone", "setuptools"]
     ignore_files = ["pip-delete-this-directory.txt", "PKG-INFO", "easy_install.py", "clonevirtualenv.py"]
     ignore_patterns = ["*.pyd", "*.so", "**/*.pyc", "*.pyc"]
-    cmd_envvars = {
-        "PIPENV_NO_INHERIT": "true",
-        "PIPENV_IGNORE_VIRTUALENVS": "true",
-        "PIPENV_VENV_IN_PROJECT": "true"
-    }
+
     patched_dir = _get_patched_dir(ctx)
     vendor_dir = _get_vendor_dir(ctx)
     safety_dir = Path(__file__).absolute().parent.joinpath("safety")
@@ -264,7 +261,7 @@ def update_safety(ctx):
         )
         log("downloading deps via pip: {0}".format(pip_command))
         ctx.run(pip_command)
-        safety_build_dir = build_dir / "safety"
+
         yaml_build_dir = build_dir / "pyyaml"
         lib_dir = safety_dir.joinpath("lib")
 
@@ -384,14 +381,15 @@ def install_pyyaml(ctx, vendor_dir):
     if build_dir.exists() and build_dir.is_dir():
         log("dropping pre-existing build dir at {0}".format(build_dir.as_posix()))
         drop_dir(build_dir)
+    build_dir.mkdir()
     with TemporaryDirectory(prefix="pipenv-", suffix="-safety") as download_dir:
         pip_command = "pip download -b {0} --no-binary=:all: --no-clean --no-deps -d {1} pyyaml safety".format(
             build_dir.absolute().as_posix(), str(download_dir.name),
         )
+        temp_env = "TEMP" if os.name == "nt" else "TMPDIR"
         log("downloading deps via pip: {0}".format(pip_command))
-        ctx.run(pip_command)
-    safety_build_dir = build_dir / "safety"
-    yaml_build_dir = build_dir / "pyyaml"
+        ctx.run(pip_command, env={temp_env: str(build_dir)})
+    yaml_build_dir = next(build_dir.glob('pip-download-*/pyyaml_*'))
     yaml_dir = vendor_dir / "yaml"
     yaml_lib_dir_map = {
         "2": {


Test patch: