Repository: pypa/pipenv

Issue:
Pipenv doesn't resolve --system python correctly.
##### Describe you environment

1. OS Type `Docker Alpine Python` -> https://github.com/docker-library/python/blob/1d59eb2dd813c64891bf554a8ea01754aba25816/3.6/alpine3.6/Dockerfile
1. Python version: `Python 3.6.3`
1. Pipenv version: `pipenv, version 8.3.1`

##### Expected result

If I set PIP_PYTHON_PATH it's ignored and overrided by pipenv (my question is why, what's reasoning behind that?) because https://github.com/kennethreitz/pipenv/blob/master/pipenv/utils.py#L367 It's overriding this ENV variable when I use flag `--system`. I've catched that issue because when building my docker image it was failing on `pipenv install --system`

Why I know this? Because there is other function that works incorrectly.
```(Pdb) python_path
'/bin/python'
(Pdb) which('python')
'/bin/python'
(Pdb) print(sys.executable)
'/usr/local/bin/python'

/ # /bin/python
sh: /bin/python: not found
```

I think issue is somewhere here: https://github.com/kennethreitz/pipenv/blob/1bf6f5101a3bf1dca78be814e742411cc5bdb2dd/pipenv/cli.py#L1440
```
            p = os.sep.join([location] + ['bin/{0}'.format(command)])
```
this should return `/usr/local/bin/python` but for some strange reason it's returning `/bin/python`

##### Actual result

`pipenv install --system` should install not failed that /bin/python is not found.

##### Steps to replicate

`pipenv install --system` on that docker image will fail


Discussion:
@galuszkak this is interesting. So `sys.executable` is set according to pdb, but we aren’t passing the fact that you used `—system` when we actually call `which()`, so it’s trying to use the project virtualenv location which presumably doesn’t exist. This is the relevant invocation which should be easy enough to fix when I get into the office: https://github.com/kennethreitz/pipenv/blob/master/pipenv/utils.py#L406

As for why we are doing all of this, it’s mainly so that we can trick the pip-fools package resolver to resolve python packages for versions of python that are different from the active interpreter 
Using this Dockerifle, which is based on the one commited to this repo I cannot reproduce this issue, not saying it doesn't exist, looks like something is up, buy this dockerfile seems to work:

```Dockerfile
FROM python:alpine3.6

# -- Install Pipenv:
RUN set -ex && pip install pipenv --upgrade

# -- Install Application into container:
RUN set -ex && mkdir /app

WORKDIR /app

# -- Adding Pipfiles
ONBUILD COPY Pipfile Pipfile
ONBUILD COPY Pipfile.lock Pipfile.lock

# -- Install dependencies:
ONBUILD RUN set -ex && pipenv install --deploy --system
```
@erinxocon I didn't use --deploy flag + You aren't using $PIP_PYTHON_PATH which is original issue here which is overriden by pipenv.
@galuszkak Apologies; I understand that, I guess I am unsure why this needs to be set in this case.  We should definitely address this bug and fix it.  I'm just wondering if there is more going on with docker alpine which required the PIP_PYTHON_PATH being set.  
@erinxocon nothing to apologise :), thanks for looking to my issue 👍 . The fix that I supply in #1005 is working for me right now.

But I tried your image and it's working perfectly fine with same set of things. Trying to naildown what is causing my problem in first place, because sam Pipfile and Pipfile.lock and same .env file sounds work on Your Dockerfile, and I don't see a difference because I source same image...
Got it @erinxocon ! Here is how can You reproduce that:
```
FROM python:3.6-alpine3.6

RUN set -ex && pip install pipenv --upgrade
RUN set -ex && mkdir /app
ENV PIP_PYTHON_PATH=/usr/local/bin/python
COPY Pipfile /app/Pipfile

WORKDIR /app
```
Pipfile:
```
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"

[packages]
flask = "*"
"flask-restful" = "*"

[dev-packages]
pytest = "*"
"pytest-flask" = "*"

[requires]
python_version = "3.6"
```

```
$ docker build . -t 'pipenv_issue:latest' --no-cache
$ docker run -it pipenv_issue:latest sh
/app # pipenv install --system
CRITICAL:pip.utils:Error [Errno 2] No such file or directory: '/bin/python': '/bin/python' while executing command python setup.py egg_info
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 1855, in install
    do_init(dev=dev, allow_global=system, ignore_pipfile=ignore_pipfile, system=system, skip_lock=skip_lock, verbose=verbose, concurrent=concurrent, deploy=deploy, pre=pre)
  File "/usr/local/lib/python3.6/site-packages/pipenv/cli.py", line 1320, in do_init
    do_lock(system=system, pre=pre)
  File "/usr/local/lib/python3.6/site-packages/pipenv/cli.py", line 1050, in do_lock
    pre=pre
  File "/usr/local/lib/python3.6/site-packages/pipenv/utils.py", line 459, in resolve_deps
    resolved_tree.update(resolver.resolve(max_rounds=PIPENV_MAX_ROUNDS))
  File "/usr/local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 102, in resolve
    has_changed, best_matches = self._resolve_one_round()
  File "/usr/local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 200, in _resolve_one_round
    for dep in self._iter_dependencies(best_match):
  File "/usr/local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 296, in _iter_dependencies
    dependencies = self.repository.get_dependencies(ireq)
  File "/usr/local/lib/python3.6/site-packages/pipenv/patched/piptools/repositories/pypi.py", line 153, in get_dependencies
    result = reqset._prepare_file(self.finder, ireq)
  File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pip/req/req_set.py", line 639, in _prepare_file
    abstract_dist.prep_for_dist()
  File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pip/req/req_set.py", line 134, in prep_for_dist
    self.req_to_install.run_egg_info()
  File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pip/req/req_install.py", line 438, in run_egg_info
    command_desc='python setup.py egg_info')
  File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pip/utils/__init__.py", line 667, in call_subprocess
    cwd=cwd, env=env)
  File "/usr/local/lib/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "/usr/local/lib/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/bin/python': '/bin/python'
```

Seems to be a problem with using ONBUILD RUN vs just RUN.  Not being a docker expert I'll have to figure out what the difference is between them.
@erinxocon I don't think that's the problem. In example above I show You problem inside running container not on any step building image.
@erinxocon the problem is with setting the variable in the first place (which doesn't actually need to be set but that's beside the point) -- by setting `PIP_PYTHON_PATH` it breaks resolver functionality when you need to pass `--system`:

```python
def which(command, location=None, allow_global=False):
    if location is None:
        location = project.virtualenv_location

    if not allow_global:
        if os.name == 'nt':
            p = find_windows_executable(os.path.join(location, 'Scripts'), command)
        else:
            p = os.sep.join([location] + ['bin/{0}'.format(command)])
    else:
        if command == 'python':
            p = sys.executable

return p
```

Since @galuszkak is using `--system` but `allow_global` doesn't get passed through by the copy of `which` that is passed to the resolver, but there is also no `Project.virtualenv_location` due to the `--system` flag, we wind up having simultaneously:

1. `location` is `None`
2. `Project.virtualenv_location` is `None` (`location` is still `None`)
3. _not_ `allow_global`
4. `p = os.sep.join([None] + ['bin/{0}'.format(python)])`

That's how we wind up with `/bin/python` as a command attempt.
@galuszkak Apologies I didn't see the -it sh flag passed in your example.  

@techalchemy makes sense. Do you have a patch in the works, or should I take that on?
@erinxocon @galuszkak already wrote a patch (#1005) which @nateprewitt had expressed some concerns about but I'm not sure where that leaves it
@erinxocon again, nothing to apologies and really thanks for looking into my issue.

Can we agree/disagree on #1005 as a fix? I will try move discussion further on that PR.
This issue hit me again today, but on OS X in totally different conditions. Stack trace below.
```
➜  saudi git:(dev) ✗ pipenv install -r requirements.txt
Warning: the environment variable LANG is not set!
We recommend setting this in ~/.profile (or equivalent) for proper expected behavior.
Creating a virtualenv for this project…
⠋Traceback (most recent call last):
  File "/usr/local/bin/pew", line 7, in <module>
    from pew.pew import pew
  File "/usr/local/lib/python3.6/site-packages/pew/__init__.py", line 11, in <module>
    from . import pew
  File "/usr/local/lib/python3.6/site-packages/pew/pew.py", line 42, in <module>
    from pew._utils import (check_call, invoke, expandpath, own, env_bin_dir,
  File "/usr/local/lib/python3.6/site-packages/pew/_utils.py", line 22, in <module>
    encoding = locale.getlocale()[1] or 'ascii'
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/locale.py", line 581, in getlocale
    return _parse_localename(localename)
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/locale.py", line 490, in _parse_localename
    raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8

Virtualenv location:
Requirements.txt found, instead of Pipfile! Converting…
Warning: Your Pipfile now contains pinned versions, if your requirements.txt did.
We recommend updating your Pipfile to specify the "*" version, instead.
Requirements file provided! Importing into Pipfile…
Creating a virtualenv for this project…
⠋Traceback (most recent call last):
  File "/usr/local/bin/pew", line 7, in <module>
    from pew.pew import pew
  File "/usr/local/lib/python3.6/site-packages/pew/__init__.py", line 11, in <module>
    from . import pew
  File "/usr/local/lib/python3.6/site-packages/pew/pew.py", line 42, in <module>
    from pew._utils import (check_call, invoke, expandpath, own, env_bin_dir,
  File "/usr/local/lib/python3.6/site-packages/pew/_utils.py", line 22, in <module>
    encoding = locale.getlocale()[1] or 'ascii'
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/locale.py", line 581, in getlocale
    return _parse_localename(localename)
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/locale.py", line 490, in _parse_localename
    raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8

Virtualenv location:
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
CRITICAL:pip.utils:Error [Errno 2] No such file or directory: '/bin/python': '/bin/python' while executing command python setup.py egg_info
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 1866, in install
    do_init(dev=dev, allow_global=system, ignore_pipfile=ignore_pipfile, system=system, skip_lock=skip_lock, verbose=verbose, concurrent=concurrent, deploy=deploy, pre=pre)
  File "/usr/local/lib/python3.6/site-packages/pipenv/cli.py", line 1330, in do_init
    do_lock(system=system, pre=pre)
  File "/usr/local/lib/python3.6/site-packages/pipenv/cli.py", line 1121, in do_lock
    pre=pre
  File "/usr/local/lib/python3.6/site-packages/pipenv/utils.py", line 461, in resolve_deps
    resolved_tree.update(resolver.resolve(max_rounds=PIPENV_MAX_ROUNDS))
  File "/usr/local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 102, in resolve
    has_changed, best_matches = self._resolve_one_round()
  File "/usr/local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 200, in _resolve_one_round
    for dep in self._iter_dependencies(best_match):
  File "/usr/local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 274, in _iter_dependencies
    for dependency in self.repository.get_dependencies(ireq):
  File "/usr/local/lib/python3.6/site-packages/pipenv/patched/piptools/repositories/pypi.py", line 153, in get_dependencies
    result = reqset._prepare_file(self.finder, ireq)
  File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pip/req/req_set.py", line 523, in _prepare_file
    abstract_dist.prep_for_dist()
  File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pip/req/req_set.py", line 134, in prep_for_dist
    self.req_to_install.run_egg_info()
  File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pip/req/req_install.py", line 438, in run_egg_info
    command_desc='python setup.py egg_info')
  File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pip/utils/__init__.py", line 667, in call_subprocess
    cwd=cwd, env=env)
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/bin/python': '/bin/python'
```
My shell was ZSH. After setting LC_ALL and LANG in .zshrc everything works fine. But I'm not sure why LANG/LC_ALL should have any impact on choosing python interpreter.
@galuszkak it is specifically an issue on Mac because of locale issues, I'll try to remember tomorrow to track down an early issue in this project where Kenneth discussed the problem with the default shell config but basically if your locale isn't set right python dies horribly

As for the PR I think we needed nate to sign off, let me ping him over in the PR
Pass `system` to the function, where `which` is being passed, and pass it to the passed `which`. 
@kennethreitz issue is not resolved, can You don't close things that aren't fixed yet. Issue is still reproducible.
no movement in 30 days. it'll come back up if its important
I'm with this problem on alpine images. Any solution?

- Python 3.6.2
- pipenv, version 8.2.6


```
Step 7/7 : RUN pipenv install --dev --system --verbose
 ---> Running in a3097251c098
Pipfile.lock (1b4750) out of date, updating to (6a9e01)…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
CRITICAL:pip.utils:Error [Errno 2] No such file or directory: '/bin/python': '/bin/python' while executing command python setup.py egg_info
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 1866, in install
    do_init(dev=dev, allow_global=system, ignore_pipfile=ignore_pipfile, system=system, skip_lock=skip_lock, verbose=verbose, concurrent=concurrent, deploy=deploy, pre=pre)
  File "/usr/local/lib/python3.6/site-packages/pipenv/cli.py", line 1325, in do_init
    do_lock(system=system, pre=pre)
  File "/usr/local/lib/python3.6/site-packages/pipenv/cli.py", line 1121, in do_lock
    pre=pre
  File "/usr/local/lib/python3.6/site-packages/pipenv/utils.py", line 461, in resolve_deps
    resolved_tree.update(resolver.resolve(max_rounds=PIPENV_MAX_ROUNDS))
  File "/usr/local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 102, in resolve
    has_changed, best_matches = self._resolve_one_round()
  File "/usr/local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 200, in _resolve_one_round
    for dep in self._iter_dependencies(best_match):
  File "/usr/local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 296, in _iter_dependencies
    dependencies = self.repository.get_dependencies(ireq)
  File "/usr/local/lib/python3.6/site-packages/pipenv/patched/piptools/repositories/pypi.py", line 153, in get_dependencies
    result = reqset._prepare_file(self.finder, ireq)
  File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pip/req/req_set.py", line 639, in _prepare_file
    abstract_dist.prep_for_dist()
  File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pip/req/req_set.py", line 134, in prep_for_dist
    self.req_to_install.run_egg_info()
  File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pip/req/req_install.py", line 438, in run_egg_info
    command_desc='python setup.py egg_info')
  File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pip/utils/__init__.py", line 667, in call_subprocess
    cwd=cwd, env=env)
  File "/usr/local/lib/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "/usr/local/lib/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/bin/python': '/bin/python'
```
This will be resolved by #1097 if and when it is merged
@kennethreitz issue has 23 days now not 30 days, so You closed it too quickly. Also there is pending PR after first one was closed. So there is still pending action on this issue... 

Please reopen issue.
I can reproduce this in the latest release (9.0.1), please reopen.
@jacebrowning thanks for the report but this wasn't fixed in 9.0.1, #1005 wasn't merged until after 9.0.1 was released.  Try with master and see if it is resolved
I just tried, `pip install git+git://github.com/pypa/pipenv.git@master` and `pipenv install --dev --system` started working in my `python:3.6.3` docker image. Can another release be made?
I can repro the problem in master. Although it is closed, the PR #1097 that suppose to solve this problem didn't actually get merged into master. Please reopen
Hi, i just found this issue today, is there another way of using Pipenv in an alpine container?
@LuRsT I just install via the git commit sha, which has the fix.

Currently waiting for a new release.

```
RUN set -ex && pip install git+git://github.com/pypa/pipenv.git@8378a1b104f2d817790a05da370bef0a1b00f452
```

EDIT: you will need to install git for this to work.
Cool, thanks @sbdchd! 
Unfortunately I'm still running into this in both `python:3.6.3` and `ubuntu:17.10` containers, with all versions of pipenv mentioned here, including the one suggested by @sbdchd .

Edit: Sorry that was a little unhelpful. I wasn't able to recreate it with a more minimal Dockerfile, so it must be something specific (and probably stupid) I'm doing. I'll report back if I find it!
Here is the Dockerfile I am using for dev:

```dockerfile
FROM python:3.6
ENV PYTHONUNBUFFERD 1

RUN apt-get update
RUN apt-get install netcat -y

# -- Install Pipenv:
RUN set -ex && pip install git+git://github.com/pypa/pipenv.git@8378a1b104f2d817790a05da370bef0a1b00f452

# -- Install Application into container:
RUN set -ex && mkdir /app

WORKDIR /app

# -- Adding Pipfiles
COPY Pipfile Pipfile
COPY Pipfile.lock Pipfile.lock

# -- Install dependencies:
RUN set -ex && pipenv install --dev --system

WORKDIR /app

VOLUME ["/app"]
```
Thanks for that. As it turns out, the error in my case was happening when attempting to create a lock file. Am transitioning some projects from `requirements.txt`'s at the moment so was installing from that in a container while tinkering around. Given that this probably isn't a recommended use-case, it's probably not worth worrying about too much?
I have added a work-around that is pretty simple to use in Docker in #917. The comment is https://github.com/pypa/pipenv/issues/917#issuecomment-375312947. While not ideal, I do think that it is quite simple. @mcgeeco; my scenario was similar to yours for wanting this, so maybe you'll find my work-around useful?
Hi there!

Just got the same issue here with the `python:3.6` Docker image and `pipenv-11.9.0`.

Here's a Dockerfile sample:

```
FROM python:3.6

WORKDIR /app
COPY . /app/

RUN pip install pipenv
RUN pipenv install --system

EXPOSE 8000

CMD ["python", "main.py"]
```

For now, I'm using @Jitsusama work-around.

Thanks.
Same here, still being hit by this.
Sorry for the ongoing trouble here folks, we had some trouble with our testing infrastructure but we will get this looked at 

Resolving patch:
diff --git a/pipenv/core.py b/pipenv/core.py
--- a/pipenv/core.py
+++ b/pipenv/core.py
@@ -1065,6 +1065,7 @@ def do_lock(
         project=project,
         clear=clear,
         pre=pre,
+        allow_global=system,
     )
     # Add develop dependencies to lockfile.
     for dep in results:
@@ -1124,6 +1125,7 @@ def do_lock(
         project=project,
         clear=False,
         pre=pre,
+        allow_global=system,
     )
     # Add default dependencies to lockfile.
     for dep in results:
diff --git a/pipenv/resolver.py b/pipenv/resolver.py
--- a/pipenv/resolver.py
+++ b/pipenv/resolver.py
@@ -24,6 +24,7 @@ def main():
     do_pre = '--pre' in ' '.join(sys.argv)
     do_clear = '--clear' in ' '.join(sys.argv)
     is_debug = '--debug' in ' '.join(sys.argv)
+    system = '--system' in ' '.join(sys.argv)
     new_sys_argv = []
     for v in sys.argv:
         if v.startswith('--'):
@@ -51,7 +52,7 @@ def main():
                 del packages[i]
     project = pipenv.core.project
 
-    def resolve(packages, pre, sources, verbose, clear):
+    def resolve(packages, pre, sources, verbose, clear, system):
         import pipenv.utils
         return pipenv.utils.resolve_deps(
             packages,
@@ -61,6 +62,7 @@ def resolve(packages, pre, sources, verbose, clear):
             sources=sources,
             clear=clear,
             verbose=verbose,
+            allow_global=system,
         )
 
     results = resolve(
@@ -69,6 +71,7 @@ def resolve(packages, pre, sources, verbose, clear):
         sources=project.sources,
         verbose=is_verbose,
         clear=do_clear,
+        system=system,
     )
     print('RESULTS:')
     if results:
diff --git a/pipenv/utils.py b/pipenv/utils.py
--- a/pipenv/utils.py
+++ b/pipenv/utils.py
@@ -372,18 +372,19 @@ class PipCommand(basecommand.Command):
 
 
 def venv_resolve_deps(
-    deps, which, project, pre=False, verbose=False, clear=False
+    deps, which, project, pre=False, verbose=False, clear=False, allow_global=False
 ):
     from . import resolver
     import json
 
     resolver = escape_grouped_arguments(resolver.__file__.rstrip('co'))
-    cmd = '{0} {1} {2} {3} {4}'.format(
+    cmd = '{0} {1} {2} {3} {4} {5}'.format(
         escape_grouped_arguments(which('python')),
         resolver,
         '--pre' if pre else '',
         '--verbose' if verbose else '',
         '--clear' if clear else '',
+        '--system' if allow_global else '',
     )
     os.environ['PIPENV_PACKAGES'] = '\n'.join(deps)
     c = delegator.run(cmd, block=True)


Test patch: