Skip to content

Unset PIP_REQUIRE_VIRTUALENV when running 'pip' #90

Closed
@adamchainz

Description

@adamchainz

This is the same issue as in pep517: pypa/pyproject-hooks#84

If PIP_REQUIRE_VIRTUALENV is set (to a non-empty value) when running python -m build , pip errors with its "ERROR: Could not find an activated virtualenv (required)." message:

$ python -m build
Looking in links: /var/folders/kq/02p9h16n7zv_z7bhzmg6y_pm0000gn/T/tmpo1xlgb08
Processing /private/var/folders/kq/02p9h16n7zv_z7bhzmg6y_pm0000gn/T/tmpo1xlgb08/setuptools-47.1.0-py3-none-any.whl
Processing /private/var/folders/kq/02p9h16n7zv_z7bhzmg6y_pm0000gn/T/tmpo1xlgb08/pip-20.1.1-py2.py3-none-any.whl
Installing collected packages: setuptools, pip
Successfully installed pip setuptools
ERROR: Could not find an activated virtualenv (required).
Traceback (most recent call last):
  File "/Users/chainz/.pyenv/versions/3.8.5/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/chainz/.pyenv/versions/3.8.5/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/chainz/.pyenv/versions/3.8.5/lib/python3.8/site-packages/build/__main__.py", line 176, in <module>
    main(sys.argv[1:], 'python -m build')
  File "/Users/chainz/.pyenv/versions/3.8.5/lib/python3.8/site-packages/build/__main__.py", line 168, in main
    build(args.srcdir, args.outdir, distributions, config_settings, not args.no_isolation, args.skip_dependencies)
  File "/Users/chainz/.pyenv/versions/3.8.5/lib/python3.8/site-packages/build/__main__.py", line 80, in build
    _build_in_isolated_env(builder, outdir, distributions)
  File "/Users/chainz/.pyenv/versions/3.8.5/lib/python3.8/site-packages/build/__main__.py", line 45, in _build_in_isolated_env
    env.install(builder.build_dependencies)
  File "/Users/chainz/.pyenv/versions/3.8.5/lib/python3.8/site-packages/build/env.py", line 176, in install
    subprocess.check_call(cmd)
  File "/Users/chainz/.pyenv/versions/3.8.5/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/Users/chainz/.pyenv/versions/3.8.5/bin/python', '-m', 'pip', 'install', '--prefix', '/var/folders/kq/02p9h16n7zv_z7bhzmg6y_pm0000gn/T/build-env-9j1lejv3', '-r', '/var/folders/kq/02p9h16n7zv_z7bhzmg6y_pm0000gn/T/build-reqs-cc8vednw.txt']' returned non-zero exit status 3.

The solution is to unset the environment variable for the subprocess.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions