Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion Error: assert not (home and prefix) #8438

Closed
weilueluo opened this issue Jun 14, 2020 · 15 comments
Closed

Assertion Error: assert not (home and prefix) #8438

weilueluo opened this issue Jun 14, 2020 · 15 comments
Labels
S: needs triage Issues/PRs that need to be triaged

Comments

@weilueluo
Copy link

Environment

  • pip version: 20.1.1
  • Python version: 3.8.3
  • OS: Windows 10

PIP_CACHE_DIR = D:\Environments\Python\pip cache dir
PIP_TARGET = D:\Environments\Python\Lib\site-packages

Description

A weird error when I tried to install pyinstaller

Expected behavior
install normally

How to Reproduce

pip install pyinstaller

Output

Collecting pyinstaller
  Using cached PyInstaller-3.6.tar.gz (3.5 MB)
  Installing build dependencies ... error
  ERROR: Command errored out with exit status 2:
   command: 'd:\environments\python\python.exe' 'd:\environments\python\lib\site-packages\pip' install --ignore-installed --no-user --prefix 'D:\Environments\TEMP\pip-build-env-siqaoa6a\overlay' --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0' wheel
       cwd: None
  Complete output (22 lines):
  Collecting setuptools>=40.8.0
    Using cached setuptools-47.1.1-py3-none-any.whl (583 kB)
  Collecting wheel
    Using cached wheel-0.34.2-py2.py3-none-any.whl (26 kB)
  Installing collected packages: setuptools, wheel
  ERROR: Exception:
  Traceback (most recent call last):
    File "d:\environments\python\lib\site-packages\pip\_internal\cli\base_command.py", line 188, in _main
      status = self.run(options, args)
    File "d:\environments\python\lib\site-packages\pip\_internal\cli\req_command.py", line 185, in wrapper
      return func(self, options, args)
    File "d:\environments\python\lib\site-packages\pip\_internal\commands\install.py", line 398, in run
      installed = install_given_reqs(
    File "d:\environments\python\lib\site-packages\pip\_internal\req\__init__.py", line 67, in install_given_reqs
      requirement.install(
    File "d:\environments\python\lib\site-packages\pip\_internal\req\req_install.py", line 769, in install
      scheme = get_scheme(
    File "d:\environments\python\lib\site-packages\pip\_internal\locations.py", line 185, in get_scheme
      scheme = distutils_scheme(
    File "d:\environments\python\lib\site-packages\pip\_internal\locations.py", line 118, in distutils_scheme
      assert not (home and prefix), "home={} prefix={}".format(home, prefix)
  AssertionError: home=D:\Environments\TEMP\pip-target-wydanjze prefix=D:\Environments\TEMP\pip-build-env-siqaoa6a\overlay
  ----------------------------------------
ERROR: Command errored out with exit status 2: 'd:\environments\python\python.exe' 'd:\environments\python\lib\site-packages\pip' install --ignore-installed --no-user --prefix 'D:\Environments\TEMP\pip-build-env-siqaoa6a\overlay' --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0' wheel Check the logs for full command output.
@triage-new-issues triage-new-issues bot added the S: needs triage Issues/PRs that need to be triaged label Jun 14, 2020
@weilueluo
Copy link
Author

It seems like PIP_TARGET and --prefix cannot be used together, but I do not know how to fix that, I want to install it to my PIP_TARGET directory.

@McSinyx
Copy link
Contributor

McSinyx commented Jun 14, 2020

Hi @Redcxx, I think that you're correct that target and prefix don't go together (I'm having GH-7828 with better error for it). Though, I wonder where you specified prefix since I couldn't see it in your command.

@weilueluo
Copy link
Author

Hi @McSinyx, I did not use --prefix. I do not understand why this error happens as well. It installs successfully if I remove the PIP_TARGET environment variables. I also have other environment variables set, not sure if they are related:

TEMP=D:\Environments\TEMP
TMP=D:\Environments\TEMP
TMPDIR=D:\Environments\TEMP

@x-yuri
Copy link

x-yuri commented Aug 15, 2020

@McSinyx The --prefix is set by pip here:

https://github.com/pypa/pip/blob/20.2.2/src/pip/_internal/build_env.py#L176

The --home is taken from PIP_TARGET:

https://github.com/pypa/pip/blob/20.2.2/src/pip/_internal/configuration.py#L330-L332
https://github.com/pypa/pip/blob/20.2.2/src/pip/_internal/cli/parser.py#L243
https://github.com/pypa/pip/blob/20.2.2/src/pip/_internal/commands/install.py#L417

It affects source (not wheel, supposedly) distribution packages. E.g.

$ pip --version
pip 20.2.2 from /app/site-packages/pip (python 3.5)

$ python --version
Python 3.5.9

$ pip install cryptography==3.0
Collecting cryptography==3.0
  Using cached cryptography-3.0.tar.gz (534 kB)
  Installing build dependencies ... error
  ERROR: Command errored out with exit status 2:
   command: /usr/local/bin/python /app/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-jhlf49yq/overlay --no-warn-script
-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.6.0' wheel 'cffi>=1.8,!=1.11.3; platform_python_implementat
ion != '"'"'PyPy'"'"''
       cwd: None
  Complete output (25 lines):
  Collecting setuptools>=40.6.0
    Using cached setuptools-49.6.0-py3-none-any.whl (803 kB)
  Collecting wheel
    Using cached wheel-0.35.1-py2.py3-none-any.whl (33 kB)
  Processing /home/app/.cache/pip/wheels/5f/f6/1a/7f35bef3818f2db90a09af3014a8fab328f0d4481aab8f039d/cffi-1.14.1-cp35-cp35m-linux_x86_64.whl
  Collecting pycparser
    Using cached pycparser-2.20-py2.py3-none-any.whl (112 kB)
  Installing collected packages: setuptools, wheel, pycparser, cffi
  ERROR: Exception:
  Traceback (most recent call last):
    File "/app/site-packages/pip/_internal/cli/base_command.py", line 220, in _main
      status = self.run(options, args)
    File "/app/site-packages/pip/_internal/cli/req_command.py", line 182, in wrapper
      return func(self, options, args)
    File "/app/site-packages/pip/_internal/commands/install.py", line 423, in run
      pycompile=options.compile,
    File "/app/site-packages/pip/_internal/req/__init__.py", line 90, in install_given_reqs
      pycompile=pycompile,
    File "/app/site-packages/pip/_internal/req/req_install.py", line 784, in install
      prefix=prefix,
    File "/app/site-packages/pip/_internal/locations.py", line 188, in get_scheme
      dist_name, user, home, root, isolated, prefix
    File "/app/site-packages/pip/_internal/locations.py", line 120, in distutils_scheme
      assert not (home and prefix), "home={} prefix={}".format(home, prefix)
  AssertionError: home=/tmp/pip-target-qt1_22bd prefix=/tmp/pip-build-env-jhlf49yq/overlay
  ----------------------------------------
ERROR: Command errored out with exit status 2: /usr/local/bin/python /app/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-en
v-jhlf49yq/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.6.0' wheel 'cffi>=1.8,!=
1.11.3; platform_python_implementation != '"'"'PyPy'"'"'' Check the logs for full command output.

pip install pycrypto==2.6.1 succeeds.

@x-yuri
Copy link

x-yuri commented Aug 15, 2020

But it works if --target is specified via command line (since this way PIP_TARGET doesn't get propagated to the subprocess):

$ pip install --target site-packages cryptography==3.0

The closest alternatives are --prefix (PIP_PREFIX), and --root (doesn't work with an environment variable either).

P.S. Make sure to set PYTHONPATH=site-packages or something to be able to import the packages.

@harish-ganesh
Copy link

harish-ganesh commented Oct 20, 2020

I'm getting a similar error too:
pip install pyEDFlib

ERROR: Command errored out with exit status 2:
   command: /home/spark/conda/envs/python3.6/bin/python /opt/ibm/conda/miniconda/lib/python/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-pjqsm6zk/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel 'numpy >= 1.9.1' cython
       cwd: None
  Complete output (29 lines):
  Collecting setuptools
    Using cached setuptools-50.3.2-py3-none-any.whl (785 kB)
  Collecting wheel
    Using cached wheel-0.35.1-py2.py3-none-any.whl (33 kB)
  Collecting numpy>=1.9.1
    Using cached numpy-1.19.2-cp36-cp36m-manylinux2010_x86_64.whl (14.5 MB)
  Collecting cython
    Using cached Cython-0.29.21-cp36-cp36m-manylinux1_x86_64.whl (2.0 MB)
  Installing collected packages: setuptools, wheel, numpy, cython
  ERROR: Exception:
AssertionError: home=/tmp/pip-target-o5x9q9xw prefix=/tmp/pip-build-env-pjqsm6zk/overlay

@bcesaralves
Copy link

I had a similar issue and solved it with the sudo's -H flag:
sudo -H pip install pyinstaller

@reox
Copy link

reox commented Mar 9, 2022

I had this problem now too while installing a local package like this: python3 -m pip install -U .
I have the PIP_TARGET variable set, which seems to be the culprit. However, I was able to workaround this, by building a wheel first and then installing the wheel:

python3 setup.py bdist_wheel
python3 -m pip install -U dist/mypackage*.whl

pip 21.2.4 / python 3.9.7
I also tested with 22.0.4 but the only difference is the new shiny error message (they look really good! But do not solve the issue 😅)

@yannbouteiller
Copy link

yannbouteiller commented Aug 9, 2022

I started having the same error on a raspberry pi and whatever I do doesn't seem to resolve the issue. I have tried uninstalling pip3 and python3, then reinstalling python3-pip with apt, which doesn't solve the issue. Where does this come from please?

@uranusjr
Copy link
Member

If you install pip from apt, this likely needs to be reported to apt, since the pip they distribute is configured differently.

@yannbouteiller
Copy link

Answer 5 here corrected it for me.

Some app had apparently added

[global]
target=/foo/bar

in ~/.config/pip/pip.conf

@PApostol
Copy link

PApostol commented Nov 16, 2022

I was getting a similar error with pip 22.3 & Python 3.7.3 on Windows 10: ERROR: Cannot set --home and --prefix together.

The work around was to remove target from the global field in file C:\Users\<USER>\AppData\Roaming\pip\pip.ini and provide the target as a CLI argument to pip install: --target path\to\site-packages.

@999iQ
Copy link

999iQ commented Jan 31, 2023

Я получал аналогичную ошибку с помощью pip 22.3 и Python 3.7.3 в Windows 10: ERROR: Cannot set --home and --prefix together.

Обходной путь заключался в удалении targetиз globalполя в файле C:\Users\<USER>\AppData\Roaming\pip\pip.iniи предоставлении целевого объекта в качестве аргумента CLI для pip install: --target path\to\site-packages.

Yes, thank you very much! This is exactly what was needed.. When I was a beginner, I accidentally registered the installation location for the first project in the pip [global] configuration file.. I couldn't install libraries properly for about 2 months and used replit ahahah.. bruh (=

@Ansud
Copy link

Ansud commented Jun 4, 2024

Here is supposed fix #12744

@sbidoul
Copy link
Member

sbidoul commented Oct 26, 2024

This was fixed by #12744, so closing.

@sbidoul sbidoul closed this as completed Oct 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S: needs triage Issues/PRs that need to be triaged
Projects
None yet
Development

No branches or pull requests