Auf CentOS 6.5 (python2.7 von SCL):
[dev<strong i="6">@centbox</strong> core]$ virtualenv-2.7 --always-copy .break
sys.path (patched logging) = ['/opt/rh/python27/root/usr/bin', '/opt/rh/python27/root/usr/lib/python2.7/site-packages/setuptools-2.2-py2.7.egg', '/opt/rh/python27/root/usr/lib/python2.7/site-packages/wheel-0.22.0-py2.7.egg', '/opt/rh/python27/root/usr/lib/python2.7/site-packages/virtualenv-1.11.2-py2.7.egg', '/opt/rh/python27/root/usr/lib/python2.7/site-packages/pip-1.5.2-py2.7.egg', '/opt/rh/python27/root/usr/lib64/python27.zip', '/opt/rh/python27/root/usr/lib64/python2.7', '/opt/rh/python27/root/usr/lib64/python2.7/plat-linux2', '/opt/rh/python27/root/usr/lib64/python2.7/lib-tk', '/opt/rh/python27/root/usr/lib64/python2.7/lib-old', '/opt/rh/python27/root/usr/lib64/python2.7/lib-dynload', '/opt/rh/python27/root/usr/lib64/python2.7/site-packages', '/opt/rh/python27/root/usr/lib/python2.7/site-packages']
Cannot find file lib (bad symlink)
New python executable in .break/bin/python2.7
Also creating executable in .break/bin/python
Installing setuptools, pip...
Complete output from command /home/dev/core/.break/bin/python2.7 -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/virtualenv-1.11.2-py2.7.egg/virtualenv_support/pip-1.5.2-py2.py3-none-any.whl/pip/__init__.py", line 9, in <module>
File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/virtualenv-1.11.2-py2.7.egg/virtualenv_support/pip-1.5.2-py2.py3-none-any.whl/pip/log.py", line 6, in <module>
File "/opt/rh/python27/root/usr/lib64/python2.7/logging/__init__.py", line 26, in <module>
import sys, os, time, cStringIO, traceback, warnings, weakref
ImportError: No module named time
----------------------------------------
...Installing setuptools, pip...done.
Traceback (most recent call last):
File "/opt/rh/python27/root/usr/bin/virtualenv-2.7", line 9, in <module>
load_entry_point('virtualenv==1.11.2', 'console_scripts', 'virtualenv-2.7')()
File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/virtualenv-1.11.2-py2.7.egg/virtualenv.py", line 824, in main
symlink=options.symlink)
File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/virtualenv-1.11.2-py2.7.egg/virtualenv.py", line 992, in create_environment
install_wheel(to_install, py_executable, search_dirs)
File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/virtualenv-1.11.2-py2.7.egg/virtualenv.py", line 960, in install_wheel
'PIP_NO_INDEX': '1'
File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/virtualenv-1.11.2-py2.7.egg/virtualenv.py", line 902, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /home/dev/core/.break/bin/python2.7 -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip failed with error code 1
Funktioniert auch ohne:
[dev<strong i="10">@centbox</strong> core]$ virtualenv-2.7 .works
sys.path (patched logging) = ['/opt/rh/python27/root/usr/bin', '/opt/rh/python27/root/usr/lib/python2.7/site-packages/setuptools-2.2-py2.7.egg', '/opt/rh/python27/root/usr/lib/python2.7/site-packages/wheel-0.22.0-py2.7.egg', '/opt/rh/python27/root/usr/lib/python2.7/site-packages/virtualenv-1.11.2-py2.7.egg', '/opt/rh/python27/root/usr/lib/python2.7/site-packages/pip-1.5.2-py2.7.egg', '/opt/rh/python27/root/usr/lib64/python27.zip', '/opt/rh/python27/root/usr/lib64/python2.7', '/opt/rh/python27/root/usr/lib64/python2.7/plat-linux2', '/opt/rh/python27/root/usr/lib64/python2.7/lib-tk', '/opt/rh/python27/root/usr/lib64/python2.7/lib-old', '/opt/rh/python27/root/usr/lib64/python2.7/lib-dynload', '/opt/rh/python27/root/usr/lib64/python2.7/site-packages', '/opt/rh/python27/root/usr/lib/python2.7/site-packages']
New python executable in .works/bin/python2.7
Also creating executable in .works/bin/python
Installing setuptools, pip...done.
[dev<strong i="11">@centbox</strong> core]$
Ich stoße auch auf dieses Problem, aber als Workaround können Sie no-setuptools
hinzufügen, um pip nicht in Ihrer virtuellen Umgebung zu installieren. Dieses Problem hängt mit der Installation von pip/setuptools in der neuen virtualenv zusammen.
Meine Versionsinformationen:
Hier ist die vollständige ausführliche Ausgabe bei einem Fehler:
[vagrant<strong i="14">@localhost</strong> ~]$ virtualenv --always-copy --clear --verbose foobar
Do not need to delete foobar/lib/python2.7; already gone
Not deleting foobar/bin
Creating foobar/lib/python2.7
Cannot find file lib (bad symlink)
Symlinking Python bootstrap modules
Copying to foobar/lib/python2.7/config
Copying to foobar/lib/python2.7/lib-dynload
Creating parent directories for foobar/lib64/python2.7
Copying to foobar/lib64/python2.7/os.py
Ignoring built-in bootstrap module: posix
Copying to foobar/lib64/python2.7/posixpath.py
Cannot import bootstrap module: nt
Copying to foobar/lib64/python2.7/ntpath.py
Copying to foobar/lib64/python2.7/genericpath.py
Copying to foobar/lib64/python2.7/fnmatch.py
Copying to foobar/lib64/python2.7/locale.py
Copying to foobar/lib64/python2.7/encodings
Copying to foobar/lib64/python2.7/codecs.py
Copying to foobar/lib64/python2.7/stat.py
Copying to foobar/lib64/python2.7/UserDict.py
Creating parent directories for foobar/lib64/python2.7/lib-dynload
Copying to foobar/lib64/python2.7/lib-dynload/readline.so
Copying to foobar/lib64/python2.7/copy_reg.py
Copying to foobar/lib64/python2.7/types.py
Copying to foobar/lib64/python2.7/re.py
Copying to foobar/lib64/python2.7/sre.py
Copying to foobar/lib64/python2.7/sre_parse.py
Copying to foobar/lib64/python2.7/sre_constants.py
Copying to foobar/lib64/python2.7/sre_compile.py
Copying to foobar/lib64/python2.7/lib-dynload/zlibmodule.so
Copying to foobar/lib64/python2.7/warnings.py
Copying to foobar/lib64/python2.7/linecache.py
Copying to foobar/lib64/python2.7/_abcoll.py
Copying to foobar/lib64/python2.7/abc.py
Copying to foobar/lib64/python2.7/_weakrefset.py
Creating foobar/lib/python2.7/site-packages
Writing foobar/lib64/python2.7/site.py
Writing foobar/lib64/python2.7/orig-prefix.txt
Writing foobar/lib64/python2.7/no-global-site-packages.txt
Creating parent directories for foobar/include
Copying to foobar/include/python2.7
Creating foobar/bin
New python executable in foobar/bin/python
Changed mode of foobar/bin/python to 0775
Copying to foobar/bin/python2
Copying to foobar/bin/python2.7
Testing executable with foobar/bin/python -c "import sys;out=sys.stdout;getattr(out, "buffer", out).write(sys.prefix.encode("utf-8"))"
Got sys.prefix result: u'/home/vagrant/foobar'
Creating foobar/lib64/python2.7/distutils
Writing foobar/lib64/python2.7/distutils/__init__.py
Writing foobar/lib64/python2.7/distutils/distutils.cfg
Installing setuptools, pip...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/virtualenv_support/pip-1.5.4-py2.py3-none-any.whl/pip/__init__.py", line 9, in <module>
File "/usr/lib/python2.7/site-packages/virtualenv_support/pip-1.5.4-py2.py3-none-any.whl/pip/log.py", line 6, in <module>
File "/usr/lib64/python2.7/logging/__init__.py", line 26, in <module>
import sys, os, time, cStringIO, traceback, warnings, weakref
ImportError: No module named time
Complete output from command /home/vagrant/foobar/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/virtualenv_support/pip-1.5.4-py2.py3-none-any.whl/pip/__init__.py", line 9, in <module>
File "/usr/lib/python2.7/site-packages/virtualenv_support/pip-1.5.4-py2.py3-none-any.whl/pip/log.py", line 6, in <module>
File "/usr/lib64/python2.7/logging/__init__.py", line 26, in <module>
import sys, os, time, cStringIO, traceback, warnings, weakref
ImportError: No module named time
----------------------------------------
...Installing setuptools, pip...done.
Traceback (most recent call last):
File "/usr/bin/virtualenv", line 11, in <module>
sys.exit(main())
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 824, in main
symlink=options.symlink)
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 992, in create_environment
install_wheel(to_install, py_executable, search_dirs)
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 960, in install_wheel
'PIP_NO_INDEX': '1'
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 902, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /home/vagrant/foobar/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip failed with error code 1
Hier ist die vollständige ausführliche Ausgabe zum Erfolg:
[vagrant<strong i="6">@localhost</strong> ~]$ virtualenv --always-copy --clear --verbose --no-setuptools foobar
Do not need to delete foobar/lib/python2.7; already gone
Not deleting foobar/bin
Creating foobar/lib/python2.7
Cannot find file lib (bad symlink)
Symlinking Python bootstrap modules
Copying to foobar/lib/python2.7/config
Copying to foobar/lib/python2.7/lib-dynload
Creating parent directories for foobar/lib64/python2.7
Copying to foobar/lib64/python2.7/os.py
Ignoring built-in bootstrap module: posix
Copying to foobar/lib64/python2.7/posixpath.py
Cannot import bootstrap module: nt
Copying to foobar/lib64/python2.7/ntpath.py
Copying to foobar/lib64/python2.7/genericpath.py
Copying to foobar/lib64/python2.7/fnmatch.py
Copying to foobar/lib64/python2.7/locale.py
Copying to foobar/lib64/python2.7/encodings
Copying to foobar/lib64/python2.7/codecs.py
Copying to foobar/lib64/python2.7/stat.py
Copying to foobar/lib64/python2.7/UserDict.py
Creating parent directories for foobar/lib64/python2.7/lib-dynload
Copying to foobar/lib64/python2.7/lib-dynload/readline.so
Copying to foobar/lib64/python2.7/copy_reg.py
Copying to foobar/lib64/python2.7/types.py
Copying to foobar/lib64/python2.7/re.py
Copying to foobar/lib64/python2.7/sre.py
Copying to foobar/lib64/python2.7/sre_parse.py
Copying to foobar/lib64/python2.7/sre_constants.py
Copying to foobar/lib64/python2.7/sre_compile.py
Copying to foobar/lib64/python2.7/lib-dynload/zlibmodule.so
Copying to foobar/lib64/python2.7/warnings.py
Copying to foobar/lib64/python2.7/linecache.py
Copying to foobar/lib64/python2.7/_abcoll.py
Copying to foobar/lib64/python2.7/abc.py
Copying to foobar/lib64/python2.7/_weakrefset.py
Creating foobar/lib/python2.7/site-packages
Writing foobar/lib64/python2.7/site.py
Writing foobar/lib64/python2.7/orig-prefix.txt
Writing foobar/lib64/python2.7/no-global-site-packages.txt
Creating parent directories for foobar/include
Copying to foobar/include/python2.7
Creating foobar/bin
New python executable in foobar/bin/python
Changed mode of foobar/bin/python to 0775
Copying to foobar/bin/python2
Copying to foobar/bin/python2.7
Testing executable with foobar/bin/python -c "import sys;out=sys.stdout;getattr(out, "buffer", out).write(sys.prefix.encode("utf-8"))"
Got sys.prefix result: u'/home/vagrant/foobar'
Creating foobar/lib64/python2.7/distutils
Writing foobar/lib64/python2.7/distutils/__init__.py
Writing foobar/lib64/python2.7/distutils/distutils.cfg
Writing foobar/bin/activate
Writing foobar/bin/activate.fish
Writing foobar/bin/activate_this.py
Writing foobar/bin/activate.csh
Sowohl im fehlgeschlagenen als auch im erfolgreichen Fall lautet die erste Fehlerzeile:
Cannot find file lib (bad symlink)
Dieses Protokoll ist nicht nützlich, da ich nicht den vollständigen Pfad zu der Datei habe, die es nicht finden kann. Ich habe daher virtualenv.py
gehackt, um os.path.abspath
für diese Datei auszudrucken und bekam:
Cannot find file /home/vagrant/lib (bad symlink)
Es sucht nach einem lib
Ordner im aktuellen Arbeitsverzeichnis.
das gleiche hier auf Centos7 mit Stock Python 2.7
$ virtualenv --always-copy /opt/
New python executable in /opt/bin/python
Installing setuptools, pip...
Complete output from command /opt/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/virtualenv_support/pip-6.0.6-py2.py3-none-any.whl/pip/__init__.py", line 4, in <module>
File "/usr/lib64/python2.7/logging/__init__.py", line 26, in <module>
import sys, os, time, cStringIO, traceback, warnings, weakref
ImportError: No module named time
----------------------------------------
...Installing setuptools, pip...done.
Traceback (most recent call last):
File "/usr/bin/virtualenv", line 11, in <module>
sys.exit(main())
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 825, in main
symlink=options.symlink)
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 993, in create_environment
install_wheel(to_install, py_executable, search_dirs)
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 961, in install_wheel
'PIP_NO_INDEX': '1'
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 903, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /opt/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip failed with error code 1
Hier gilt das gleiche. Bei Verwendung von --always-copy
auf CentOS 6.5 endet das System Python 2.6 mit dem gleichen ImportError: No module named time
wie erwähnt.
Die Lösung besteht darin, die Option --always-copy bei EL-basierten Distributionen zu vergessen
Es scheint einen Tippfehler in der Funktion fix_lib64 zu geben, die derzeit ausgeführt wird. Ich korrigiere dies und es funktioniert wie erwartet. gehe zur Zeile:
1579 if symlink:
1580 os.symlink('lib', lib64_link)
1581 else:
1582 copyfile('lib', lib64_link)
Ersetze 'lib'
durch lib_dir
1579 if symlink:
1580 os.symlink(lib_dir, lib64_link)
1581 else:
1582 copyfile(lib_dir, lib64_link)
Verspätung, aber hoffe das hilft
Ich habe auch hier das gleiche Problem mit CentOS 7.1 mit den Flags --no-setup-tools
und --always-copy
. Ich würde es lieben, wenn dies behoben wird, da ich die Virtualenv verpacke und an Kunden versende (die auch auf CentOS7 + sind, also kein großes Risiko).
Das gleiche hier auf Gentoo x86_64 mit --always-copy
.
@jdelgad und @selurvedu hast du versucht, was ich oben empfohlen habe?
@ikiini Ja, Ihr Patch
@ikiini Es hat funktioniert! Ich danke dir sehr. Um dies nun entweder in RHEL 7 oder in den Hauptzweig zu bekommen.
+1
Großartig. Entschuldigung für die verspätete Antwort..aber Sie sind herzlich willkommen
Das einzige Problem scheint zu sein, dass @ikiinis Patch auf https://github.com/pypa/virtualenv/issues/338 zurückfällt , als er tatsächlich von lib_dir
auf 'lib'
geändert wurde
Das Problem besteht weiterhin mit CentOS 7 und Python 2.7
[root@st2w-master-el7-5696a8a082 ~]# virtualenv no_copy
New python executable in no_copy/bin/python
Installing setuptools, pip, wheel...done.
[root@st2w-master-el7-5696a8a082 ~]# virtualenv --always-copy yes_copy
Cannot find file lib (bad symlink)
New python executable in yes_copy/bin/python
Installing setuptools, pip, wheel...
Complete output from command /root/yes_copy/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/__init__.py", line 4, in <module>
File "/usr/lib64/python2.7/logging/__init__.py", line 26, in <module>
import sys, os, time, cStringIO, traceback, warnings, weakref
ImportError: No module named time
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "/bin/virtualenv", line 11, in <module>
sys.exit(main())
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 832, in main
symlink=options.symlink)
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 1004, in create_environment
install_wheel(to_install, py_executable, search_dirs)
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 969, in install_wheel
'PIP_NO_INDEX': '1'
File "/usr/lib/python2.7/site-packages/virtualenv.py", line 910, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /root/yes_copy/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel failed with error code 1
[root@st2w-master-el7-5696a8a082 ~]# virtualenv --version
13.1.2
[root@st2w-master-el7-5696a8a082 ~]# ls -rlth yes_copy/
total 0
drwxr-xr-x. 3 root root 22 Jan 13 22:04 lib
drwxr-xr-x. 3 root root 22 Jan 13 22:04 lib64
drwxr-xr-x. 3 root root 22 Jan 13 22:04 include
drwxr-xr-x. 2 root root 49 Jan 13 22:04 bin
[root@st2w-master-el7-5696a8a082 ~]#
@bwilliams42 - Ihre Änderung hat tatsächlich das Problem für die Symlink-Logik behoben. Die Dinge sind jedoch grundsätzlich kaputt, wenn --always-copy nicht verwendet wird. Beachten Sie, dass copyfile einen "symlink"-kwarg hat, der standardmäßig auf True gesetzt ist. Die folgende Logik ist effektiv, wenn Symlink os.symlink aufrufen, sonst copyfile ohne den "symlink"-Kwarg aufrufen, was dazu führt, dass Copyfile standardmäßig symlink=True setzt und ein Symlink von copyfile erstellt wird. Gar nicht sinnvoll. Ein Symlink ist das Ergebnis, egal was passiert.
Sollte der Patch nicht etwa wie folgt aussehen?
1579 if symlink:
1580 os.symlink(lib_dir, lib64_link)
1581 else:
1582 copyfile(lib_dir, lib64_link, symlink=symlink)
Ich hatte ein Problem, bei dem ich dies tat, und ich hatte einen Symlink zu /usr/lib64. Als RH einige der openssl-Bibliotheken aktualisierte, war dies defekt (ich habe ansible verwendet) mit einem Fehler, der etwas wie openssl_meth function
angab. Ich habe es behoben, indem ich eine tiefe Kopie von /usr/lib64 erstellt habe. Keine vollständige Lösung @bwilliams42, aber es hat mich in die richtige Richtung
Das Problem besteht weiterhin bei Centos 7.2. Dieses Ticket wurde vor 2,5 Jahren gemeldet. Es scheint ein sehr ernstes Problem zu sein. Wie kann ich helfen, es zu beheben?
Jemand muss eine funktionierende Lösung bereitstellen. Hier wurde ein Fix vorgeschlagen, der jedoch anscheinend einige Probleme aufweist. Ich würde vorschlagen, dort anzufangen.
Übrigens, ich versuche, meine Python-Anwendung mit Hilfe von Fabric auf einer speziellen VM unter Vagrant zu erstellen und in eine virtuelle Umgebung zu packen.
Ich habe kein inneres Wissen darüber, wie virtualenv funktionieren soll, also brauche ich etwas Anleitung.
Ich kann da leider nicht helfen, da ich unter Windows arbeite und die ganze Frage von Symlinking vs.
Interessant, dass (ich bin auf Amazon Linux) wenn ich virtualenv --always-copy app
mache, erhalte ich diese Fehlermeldung ( Cannot find file lib (bad symlink)
), aber wenn ich mkdir app; cd app; virtualenv --always-copy .
mache, erhalte ich es nicht. Und es scheint, ich verstehe warum - wenn app
von der virtuellen Umgebung erstellt wird, hat sie lib64
als Verzeichnis, aber wenn ich die virtuelle Umgebung im aktuellen Verzeichnis erstelle, wird sie zu einem Link zu lib
.
virtualenv.py
> def path_locations
beginnt mit diesem Kommentar:
XXX: Wir würden distutils.sysconfig.get_python_inc/lib verwenden, aber es ist
Präfix arg ist defekt: http://bugs.python.org/issue3386
Dieses Problem wurde vor etwa zehn Jahren gelöst. Vielleicht überdenken Sie es, es zu verwenden?
Geben Sie einfach einen anderen Blickwinkel; Eine zuverlässige Lösung für alle Plattformen zu schreiben, ist keine leichte Aufgabe.
@kika Vielen Dank.
Dieses Problem wurde automatisch als veraltet markiert, da es in letzter Zeit keine Aktivität hatte. Es wird geschlossen, wenn keine weitere Aktivität stattfindet. Fügen Sie einfach einen Kommentar hinzu, wenn Sie ihn geöffnet lassen möchten. Vielen Dank für Ihre Beiträge.
Dies wird obsolet, da #1366 jetzt in vollem Gange ist. Wir öffnen wieder, wenn noch jemand damit replizieren kann.
Hilfreichster Kommentar
Interessant, dass (ich bin auf Amazon Linux) wenn ich
virtualenv --always-copy app
mache, erhalte ich diese Fehlermeldung (Cannot find file lib (bad symlink)
), aber wenn ichmkdir app; cd app; virtualenv --always-copy .
mache, erhalte ich es nicht. Und es scheint, ich verstehe warum - wennapp
von der virtuellen Umgebung erstellt wird, hat sielib64
als Verzeichnis, aber wenn ich die virtuelle Umgebung im aktuellen Verzeichnis erstelle, wird sie zu einem Link zulib
.