Vielen Dank für die Einreichung eines Problems!
Wenn Sie einen BUG einreichen, geben Sie bitte Folgendes an:
-vvv --with-traceback
pip list
der Umgebung, in der virtualenv installiert ist, wenn die zipapp nicht verwendet wirdIch habe eine minimal reproduzierbare Docker-Datei erstellt, die selbsterklärend ist:
FROM ubuntu:16.04
RUN apt-get update && apt-get install -y --no-install-recommends \
python python-pip python-pkg-resources python-setuptools python-wheel python-dev libxslt1-dev
RUN pip install virtualenv --disable-pip-version-check --no-cache-dir
WORKDIR /root
RUN virtualenv venv
Vollständiges Installationsprotokoll:
UN pip install virtualenv --disable-pip-version-check --no-cache-dir
---> Running in 92fa3d30b758
Collecting virtualenv
Downloading https://files.pythonhosted.org/packages/a3/dd/e43866ac0d25cd1ecbde0814f6cd7372ea257fbdf443dc9f0a01740da93d/virtualenv-20.0.4-py2.py3-none-any.whl (4.6MB)
Collecting six<2,>=1.9.0 (from virtualenv)
Downloading https://files.pythonhosted.org/packages/65/eb/1f97cb97bfc2390a276969c6fae16075da282f5058082d4cb10c6c5c1dba/six-1.14.0-py2.py3-none-any.whl
Collecting distlib<1,>=0.3.0 (from virtualenv)
Downloading https://files.pythonhosted.org/packages/7d/29/694a3a4d7c0e1aef76092e9167fbe372e0f7da055f5dcf4e1313ec21d96a/distlib-0.3.0.zip (571kB)
Collecting importlib-metadata<2,>=0.12; python_version < "3.8" (from virtualenv)
Downloading https://files.pythonhosted.org/packages/8b/03/a00d504808808912751e64ccf414be53c29cad620e3de2421135fcae3025/importlib_metadata-1.5.0-py2.py3-none-any.whl
Collecting appdirs<2,>=1.4.3 (from virtualenv)
Downloading https://files.pythonhosted.org/packages/56/eb/810e700ed1349edde4cbdc1b2a21e28cdf115f9faf263f6bbf8447c1abf3/appdirs-1.4.3-py2.py3-none-any.whl
Collecting importlib-resources<2,>=1.0; python_version < "3.7" (from virtualenv)
Downloading https://files.pythonhosted.org/packages/2f/f7/b4aa02cdd3ee7ebba375969d77c00826aa15c5db84247d23c89522dccbfa/importlib_resources-1.0.2-py2.py3-none-any.whl
Collecting filelock<4,>=3.0.0 (from virtualenv)
Downloading https://files.pythonhosted.org/packages/14/ec/6ee2168387ce0154632f856d5cc5592328e9cf93127c5c9aeca92c8c16cb/filelock-3.0.12.tar.gz
Collecting contextlib2<1,>=0.6.0; python_version < "3.3" (from virtualenv)
Downloading https://files.pythonhosted.org/packages/85/60/370352f7ef6aa96c52fb001831622f50f923c1d575427d021b8ab3311236/contextlib2-0.6.0.post1-py2.py3-none-any.whl
Collecting pathlib2<3,>=2.3.3; python_version < "3.4" and sys_platform != "win32" (from virtualenv)
Downloading https://files.pythonhosted.org/packages/e9/45/9c82d3666af4ef9f221cbb954e1d77ddbb513faf552aea6df5f37f1a4859/pathlib2-2.3.5-py2.py3-none-any.whl
Collecting zipp>=0.5 (from importlib-metadata<2,>=0.12; python_version < "3.8"->virtualenv)
Downloading https://files.pythonhosted.org/packages/60/85/668bca4a9ef474ca634c993e768f12bd99af1f06bb90bb2655bc538a967e/zipp-2.2.0.tar.gz
Running setup.py (path:/tmp/pip-build-pW7K_Y/zipp/setup.py) egg_info for package zipp produced metadata for project name unknown. Fix your #egg=zipp fragments.
Collecting configparser>=3.5; python_version < "3" (from importlib-metadata<2,>=0.12; python_version < "3.8"->virtualenv)
Downloading https://files.pythonhosted.org/packages/7a/2a/95ed0501cf5d8709490b1d3a3f9b5cf340da6c433f896bbe9ce08dbe6785/configparser-4.0.2-py2.py3-none-any.whl
Collecting typing; python_version < "3.5" (from importlib-resources<2,>=1.0; python_version < "3.7"->virtualenv)
Downloading https://files.pythonhosted.org/packages/22/30/64ca29543375759dc589ade14a6cd36382abf2bec17d67de8481bc9814d7/typing-3.7.4.1-py2-none-any.whl
Collecting scandir; python_version < "3.5" (from pathlib2<3,>=2.3.3; python_version < "3.4" and sys_platform != "win32"->virtualenv)
Downloading https://files.pythonhosted.org/packages/df/f5/9c052db7bd54d0cbf1bc0bb6554362bba1012d03e5888950a4f5c5dadc4e/scandir-1.10.0.tar.gz
Installing collected packages: six, distlib, contextlib2, unknown, scandir, pathlib2, configparser, importlib-metadata, appdirs, typing, importlib-resources, filelock, virtualenv
Running setup.py install for distlib: started
Running setup.py install for distlib: finished with status 'done'
Running setup.py install for unknown: started
Running setup.py install for unknown: finished with status 'done'
Running setup.py install for scandir: started
Running setup.py install for scandir: finished with status 'done'
Running setup.py install for filelock: started
Running setup.py install for filelock: finished with status 'done'
Successfully installed appdirs-1.4.3 configparser-4.0.2 contextlib2-0.6.0.post1 distlib-0.3.0 filelock-3.0.12 importlib-metadata-1.5.0 importlib-resources-1.0.2 pathlib2-2.3.5 scandir-1.10.0 six-1.14.0 typing-3.7.4.1 unknown-0.0.0 virtualenv-20.0.4
Removing intermediate container 92fa3d30b758
---> 6127ebfdaa58
Step 5/6 : WORKDIR /root
---> Running in 3998fd059d5e
Removing intermediate container 3998fd059d5e
---> 62a1db87d19c
Step 6/6 : RUN virtualenv venv
---> Running in c40b1478666a
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 7, in <module>
from virtualenv.__main__ import run_with_catch
File "/usr/local/lib/python2.7/dist-packages/virtualenv/__init__.py", line 3, in <module>
from .run import cli_run
File "/usr/local/lib/python2.7/dist-packages/virtualenv/run/__init__.py", line 9, in <module>
from .plugin.activators import ActivationSelector
File "/usr/local/lib/python2.7/dist-packages/virtualenv/run/plugin/activators.py", line 6, in <module>
from .base import ComponentBuilder
File "/usr/local/lib/python2.7/dist-packages/virtualenv/run/plugin/base.py", line 9, in <module>
from importlib_metadata import entry_points
File "/usr/local/lib/python2.7/dist-packages/importlib_metadata/__init__.py", line 9, in <module>
import zipp
ImportError: No module named zipp
The command '/bin/sh -c virtualenv venv' returned a non-zero code: 1
Die gleichen Befehle funktionieren, wenn ich die Versionsnummer von Ubuntu auf 18.04 ändere
Also habe ich Hilfe im IRC bekommen, pip install -U pip
dieses Problem behoben.
Trotzdem wäre dies entweder großartig:
Wir haben dies erst heute mit https://github.com/pypa/virtualenv/pull/1628 verbessert
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3241, in <module>
<strong i="7">@_call_aside</strong>
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3225, in _call_aside
f(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3254, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 585, in _build_master
return cls._build_from_requirements(__requires__)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 598, in _build_from_requirements
dists = ws.resolve(reqs, Environment())
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 786, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'zipp>=0.5' distribution was not found and is required by importlib-metadata
Da die zipp-Pakete nicht mit setuptools 41.0.0 funktionieren können ...
setuptools 42.0.0 funktioniert in diesem Fall jedoch 👍
Dies ist kein Fehler in virtualenv. Wenn Sie pip install zipp
, wird das gleiche Problem auftreten
Es ist eine Kombination aus zwei Dingen:
pip<9
ignoriert python_requires
Auswahl der neuesten Versionpy36-none-any
-Rad nicht verwenden, daher muss es aus dem Quellcode erstellt werdensetuptools<30.3
kann keine deklarativen Metadatenpakete aus dem Quellcode erstellenSo erhalten Sie:
zipp
auf python2.x mit dem Namen "unknown == 0.0.0"Die einfachste Lösung besteht darin, eine neuere Version von pip
zu verwenden, um virtualenv
zu installieren oder die Zip-App zu verwenden
@gaborbernat Ich glaube nicht, dass dies virtualenv selbst ist, da dort ein py2.py3-none-any
-Rad bereitgestellt wird, das bis zu pip==1.5
zurückverwendet wird
Ja, es ist nicht selbst; aber unsere Benutzer sind davon betroffen; Ich bin versucht, https://github.com/pypa/virtualenv/blob/master/setup.py#L4 auf 42 zu bringen ... was es zu lösen scheint.
Dieser Code wird überhaupt nicht ausgeführt, wenn er von einem Rad installiert wird
Aus Anwendersicht wäre das Beste eine Fehlermeldung mit der Aufschrift: "Nicht unterstützte Pip-Version, bitte zuerst 'pip install -U pip' ausführen".
Im Falle einer Radmontage können wir nichts tun, das Problem ist bereits vorbei. Wenn jemand von der Quelle installiert, benötigt er nicht unbedingt neuere Pip, sondern nur neuere Setuptools. Wenn sie neuere Setuptools haben, können wir mit etwas hilfreicherem scheitern. Dies ist das Beste, was wir hier tun können, glaube ich.
Sie können dies sogar zur Laufzeit anzeigen. Es sollte einfach eine Fehlermeldung angezeigt werden, wenn es auf sehr alten Pip-Versionen ausgeführt wird.
@gaborbernat das hilft aber nicht, pip installiert immer noch eine Version von zipp
, die nicht mit dem laufenden Python kompatibel ist (1.1 ist die letzte Version, die python2.x unterstützt):
$ virtualenv venv -ppython2
Running virtualenv with interpreter /usr/bin/python2
Already using interpreter /usr/bin/python2
New python executable in /tmp/y/venv/bin/python2
Also creating executable in /tmp/y/venv/bin/python
Installing setuptools, pip, wheel...
done.
$ . venv/bin/activate
$ pip install 'pip<9' 'setuptools>=42'
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting pip<9
Using cached pip-8.1.2-py2.py3-none-any.whl (1.2 MB)
Requirement already satisfied: setuptools>=42 in ./venv/lib/python2.7/site-packages (44.0.0)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.0.2
Uninstalling pip-20.0.2:
Successfully uninstalled pip-20.0.2
Successfully installed pip-8.1.2
$ pip install zipp
Collecting zipp
Downloading https://files.pythonhosted.org/packages/60/85/668bca4a9ef474ca634c993e768f12bd99af1f06bb90bb2655bc538a967e/zipp-2.2.0.tar.gz
Building wheels for collected packages: zipp
Running setup.py bdist_wheel for zipp ... done
Stored in directory: /home/asottile/.cache/pip/wheels/a0/1f/9d/d132b3fbc38b33322681e3a7830c0a29fce7f55c3a06b85c65
Successfully built zipp
Installing collected packages: zipp
Successfully installed zipp-2.2.0
You are using pip version 8.1.2, however version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Wenn ich das durchdenke, denke ich nicht, dass wir hier etwas tun können. Wenn es bereits installiert ist, können wir nur manuell überprüfen, ob unsere Abhängigkeiten korrekt sind ... und das ist sehr teuer.
Alles, was wir hier tun müssen, ist zu dokumentieren, was @asottile oben gemäß https://github.com/pypa/virtualenv/issues/1618 gesagt hat
Aus Anwendersicht wäre das Beste eine Fehlermeldung mit der Aufschrift: "Nicht unterstützte Pip-Version, bitte zuerst 'pip install -U pip' ausführen".
Angesichts der Tatsache, dass pip bereits eine Warnung ausgibt (die Sie im Docker-Skript deaktiviert haben), wenn Sie eine ältere Version verwenden, die auf ein Upgrade hinweist, würde das Hinzufügen einer weiteren Meldung, die Sie darüber informiert, dass Sie eine veraltete Version verwenden, tatsächlich helfen?
(Das ist keine rhetorische oder sarkastische Frage. Eines der großen Probleme bei Python-Verpackungen besteht darin, dass ältere Versionen der Tools diese nicht unterstützen, wenn wir neue Standards einführen, und wir müssen den besten Weg finden, um die Benutzer zu ermutigen, Schritt zu halten Daher ist es uns sehr wichtig zu wissen, was funktioniert und was nicht, wie wir versuchen, die Nachricht an die Benutzer weiterzugeben.
Ich stelle fest, dass Sie im Docker-Skript deaktiviert sind
Wo? Ich sehe alle Warnungen, Python 2.7 EOL usw.
Vielleicht ist das Beste, was wir tun können, dies hier für Google zu haben. Zumindest jetzt findet es dieses Problem für "ImportError: Kein Modul mit dem Namen zipp", damit die Leute das Pip-Update-Update finden können.
--disable-pip-version-check
Dies wird in Dockerfile benötigt, um ein Caching zu vermeiden. Ich dachte an eine Art Warnung wie die roten 2.7 EOL-Linien, die sehr gut sichtbar sind.
Also habe ich es ohne versucht und es zeigt nur, dass es bedeutungslos ist.
You are using pip version 8.1.1, however version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Linie. Natürlich deaktiviert dies jeder in Dockerfiles, da dies immer angezeigt wird, selbst sobald 20.0.3 veröffentlicht wird.
Trotz der neuesten Version von pip wird dieses Problem immer noch angezeigt:
$ pip3 --version
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
pip 20.2.3 from /Users/jackjack/Library/Python/3.7/lib/python/site-packages/pip (python 3.7)
$ pip3 install -U pip
# removing repeated "pip is being invoked by an old script wrapper" messages
Defaulting to user installation because normal site-packages is not writeable
Requirement already up-to-date: pip in /Users/jackjack/Library/Python/3.7/lib/python/site-packages (20.2.3)
$ pip3 install -U pip3
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement pip3 (from versions: none)
ERROR: No matching distribution found for pip3
$ pip3 install -U virtualenv
Defaulting to user installation because normal site-packages is not writeable
Requirement already up-to-date: virtualenv in /Users/jackjack/Library/Python/3.7/lib/python/site-packages (20.0.33)
Requirement already satisfied, skipping upgrade: distlib<1,>=0.3.1 in /Users/jackjack/Library/Python/3.7/lib/python/site-packages (from virtualenv) (0.3.1)
Requirement already satisfied, skipping upgrade: appdirs<2,>=1.4.3 in /Users/jackjack/Library/Python/3.7/lib/python/site-packages (from virtualenv) (1.4.4)
Requirement already satisfied, skipping upgrade: importlib-metadata<3,>=0.12; python_version < "3.8" in /Users/jackjack/Library/Python/3.7/lib/python/site-packages (from virtualenv) (2.0.0)
Requirement already satisfied, skipping upgrade: six<2,>=1.9.0 in /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages (from virtualenv) (1.12.0)
Requirement already satisfied, skipping upgrade: filelock<4,>=3.0.0 in /Users/jackjack/Library/Python/3.7/lib/python/site-packages (from virtualenv) (3.0.12)
Requirement already satisfied, skipping upgrade: zipp>=0.5 in /Users/jackjack/Library/Python/3.7/lib/python/site-packages (from importlib-metadata<3,>=0.12; python_version < "3.8"->virtualenv) (3.3.0)
$ sudo /usr/bin/easy_install virtualenv
Searching for virtualenv
Best match: virtualenv 20.0.33
Processing virtualenv-20.0.33-py2.7.egg
virtualenv 20.0.33 is already the active version in easy-install.pth
Installing virtualenv script to /usr/local/bin
Using /Library/Python/2.7/site-packages/virtualenv-20.0.33-py2.7.egg
Processing dependencies for virtualenv
Searching for zipp>=0.4
Reading https://pypi.org/simple/zipp/
Downloading https://files.pythonhosted.org/packages/7b/50/8a41d217ae898bb7a422a55a2a2afc22dfaab42b7bce5fe771a3892fe5e7/zipp-3.3.0.tar.gz#sha256=64ad89efee774d1897a58607895d80789c59778ea02185dd846ac38394a8642b
Best match: zipp 3.3.0
Processing zipp-3.3.0.tar.gz
Writing /tmp/easy_install-QuPyHI/zipp-3.3.0/setup.cfg
Running zipp-3.3.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-QuPyHI/zipp-3.3.0/egg-dist-tmp-2lSPpU
File "build/bdist.macosx-10.15-x86_64/egg/zipp.py", line 240
def open(self, mode='r', *args, pwd=None, **kwargs):
^
SyntaxError: invalid syntax
zip_safe flag not set; analyzing archive contents...
Removing /Library/Python/2.7/site-packages/zipp-0.0.0-py2.7.egg
Copying zipp-0.0.0-py2.7.egg to /Library/Python/2.7/site-packages
zipp 0.0.0 is already the active version in easy-install.pth
Installed /Library/Python/2.7/site-packages/zipp-0.0.0-py2.7.egg
error: The 'zipp>=0.4' distribution was not found and is required by importlib-resources
$ /usr/bin/easy_install virtualenv
error: can't create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory:
[Errno 13] Permission denied: '/Library/Python/2.7/site-packages/test-easy-install-20543.write-test'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/Library/Python/2.7/site-packages/
Perhaps your account does not have write access to this directory? If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account. If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.
For information on other options, you may wish to consult the
documentation at:
https://setuptools.readthedocs.io/en/latest/easy_install.html
Please make the appropriate changes for your system and try again.
Ähnliche Fehler, auch wenn ich sudo pip3 install
'd virtualenv
easy_install
ist kein Pip, benutze es nicht, es ist nie das, was du willst
Verschiedene Anleitungen (einschließlich dieser ) behaupten, dass es sich um eine Lösung für dieses Problem handelt (wobei virtualenv
über pip
installiert wird, aber auf PATH
nicht auffindbar ist). Was würden Sie als Alternative vorschlagen?
Huch, folge definitiv nicht ihrem Rat
In Ihrem Fall führen Sie eine --user
-Installation durch, was bedeutet, dass Sie das richtige bin-Verzeichnis in das PATH
- wahrscheinlich /Users/jackjack/Library/Python/3.7/bin
wenn ich raten müsste (obwohl) Ich bin nicht mit Macos vertraut.
Die erste Installation hätte Sie davor warnen sollen (Sie können die Nachrichten wahrscheinlich mit pip3 uninstall virtualenv && pip3 install virtualenv
erneut
Hmmm, interessant. Es stellt sich also heraus, dass es bereits eine Datei a /usr/local/bin/virtualenv
mit folgendem Inhalt gibt:
#!/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
# EASY-INSTALL-ENTRY-SCRIPT: 'virtualenv==20.0.33','console_scripts','virtualenv'
__requires__ = 'virtualenv==20.0.33'
import re
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(
load_entry_point('virtualenv==20.0.33', 'console_scripts', 'virtualenv')()
)
Beachten Sie, dass es im Shebang auf 2.7 fest codiert ist, was wahrscheinlich die Ursache für einige der Probleme ist, da ich mit pip3
installiere.
Ich musste sicherstellen, dass dieser Pfad hinzugefügt wurde (den Sie richtig erraten haben - und der bei der Neuinstallation auch von pip3 install virtualenv
ausgegeben wurde!) _Vor_ /usr/local/bin
, um sicherzustellen, dass er Vorrang hat. Jetzt arbeiten - danke!
Ich würde vorschlagen, dieses zu deinstallieren, aber lol, easy_install
hat keine Deinstallation (das war eine der großen Funktionen, die Pip beim Ersetzen von easy_install
auf den Tisch gebracht hat).
Hilfreichster Kommentar
Also habe ich Hilfe im IRC bekommen,
pip install -U pip
dieses Problem behoben.Trotzdem wäre dies entweder großartig: