beheben von Pip-Installationsfehlern unter Windows mit folgendem Fehler. Dieser Fehler wird angezeigt, wenn versucht wird, ansible zu installieren.
Ich vermute, es liegt ein Problem mit dem ausgewählten Pip-Paket für die Installation vor. Aber das gleiche funktioniert gut mit Linux-basierten Systemen. Gibt es einen Unterschied zum Betriebssystem für die Pip-Installation?
Exception:
Traceback (most recent call last):
File "c:\python27\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "c:\python27\lib\site-packages\pip\commands\install.py", line 324, in run
requirement_set.prepare_files(Finder)
File "c:\python27\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "c:\python27\lib\site-packages\pip\req\req_set.py", line 620, in _prepare_file
session=self.session, hashes=hashes)
File "c:\python27\lib\site-packages\pip\download.py", line 821, in unpack_url
hashes=hashes
File "c:\python27\lib\site-packages\pip\download.py", line 663, in unpack_http_url
unpack_file(from_path, location, content_type, link)
File "c:\python27\lib\site-packages\pip\utils\__init__.py", line 605, in unpack_file
untar_file(filename, location)
File "c:\python27\lib\site-packages\pip\utils\__init__.py", line 553, in untar_file
ensure_dir(path)
File "c:\python27\lib\site-packages\pip\utils\__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "C:\Python27\Lib\os.py", line 157, in makedirs
mkdir(name, mode)
WindowsError: [Error 206] The filename or extension is too long: 'c:\\users\\user123\\appdata\\local\\temp\\pip-build-isnb2t\\ansible\\test/integration/targets/copy/files/subdir/subdir1/circles/subdir1/circles/subdir1/circles/subdir1/circles/subdir1/circles/subdir1/circles/subdir1/circles/subdir1/circles/subdir1/circles/subdir1/'
Nun, es scheint ein bekannter Fehler zu sein:
https://github.com/ansible/ansible/issues/31419
In ansible 2.4.0 verwendet die Modul Kopie symbolische Links in den Tests Suite: https://github.com/ansible/ansible/tree/devel/test/integration/targets/copy/files/subdir/subdir1
circles -> ../
subdir3 -> ../subdir2/subdir3
Windows 10 kann diesen Verzeichnisbaum nicht erstellen, da der Pfad zu lang ist. Tatsächlich lautet der aufgelöste Pfad:
test/integration/targets/copy/files/subdir/subdir1/circles/subdir1/circles/subdir1/circles/subdir1/circles/subdir1/circles/subdir1/circles/subdir1/circles/subdir1/circles/subdir2/subdir3/
fehlerbericht endet mit:
Die Installation von Ansible direkt auf einem Windows-Computer wird nicht unterstützt. Sie benötigen ein Linux-ähnliches Betriebssystem, um ansible auf zu installieren
Eine mögliche Problemumgehung besteht darin, das Rad auf pypi herunterzuladen, es hängt nicht von Linux oder was auch immer ab, wahrscheinlich von reinem Python:
https://pypi.python.org/pypi/ansible/2.5.0a
(Der Befehl pip install ansible
lädt das .tgz-Archiv "source" herunter, führt Tests durch, ... und das Pfadproblem liegt innerhalb der Tests. Verwenden wir also ein gebrauchsfertiges vorgefertigtes Bundle.)
Einmal heruntergeladen, benutze pip install path/to/the/wheel/file.whl
Getestet und erfolgreich auf meinem Windows 10-Computer installiert:
C:\Users\jotd>c:\Python27\Scripts\pip install C:\Users\jotd\Downloads\ansible-2.5.0a1-py2-none-any.whl
Processing c:\users\jotd\downloads\ansible-2.5.0a1-py2-none-any.whl
Requirement already satisfied: PyYAML in c:\python27\lib\site-packages (from ansible==2.5.0a1)
Collecting cryptography (from ansible==2.5.0a1)
<a lot of package collecting...>
Installing collected packages: idna, pycparser, cffi, asn1crypto, ipaddress, cryptography, pynacl, bcrypt, pyasn1, paramiko, ansible
Running setup.py install for pycparser ... done
Running setup.py install for ipaddress ... done
Successfully installed ansible-2.5.0a1 asn1crypto-0.24.0 bcrypt-3.1.4 cffi-1.11.4 cryptography-2.1.4 idna-2.6 ipaddress-1.0.19 paramiko-2.4.0 pyasn1-0.4.2 pycparser-2.18 pynacl-1.2.1
ok, installiert, aber versuchen wir es zu importieren:
C:\Users\jotd>c:\python27\python
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ansible
>>>
funktioniert! Yay!
Ich wurde ansible ohne Pip installiert, was mir ziemlich direkt vorkam.
Schritte:
laden Sie das komprimierte .tgz-Archiv von https://pypi.org/project/ansible/ herunter.
Öffne 7-Zip mit der rechten Maustaste als Administrator ausführen und extrahiere. <- admin wird wegen symbolischer Links benötigt
öffnete eine Admin-Konsole im Ordner und lief:
python setup.py installieren
jetzt ist ansible unter Windows installiert.
Ich hatte auch Probleme mit der Installation von Ansible auf Windows. Anstatt zu versuchen, ansible auf einer Plattform zu installieren, ist es nicht dafür gedacht, das Windows Ubuntu-Subsystem zu aktivieren.
Siehe https://tutorials.ubuntu.com/tutorial/tutorial-ubuntu-on-windows
Sobald Sie dies getan haben, install ansible durch apt-get oder pip.
-
Installation mit PIP:
Stellen Sie sicher, dass Sie zuerst python3-disutils haben:
Sudo kann python3-distutils installieren
und dann installiere pip gemäß https://pip.pypa.io/en/stable/installing/
Versuchen Sie es mit ansible - wenn es nicht gefunden werden kann, müssen Sie das Verzeichnis site-packages zu Ihrem $ PATH hinzufügen.
Um all diese Installationsarbeiten zu vermeiden, empfehle ich die Verwendung von apt-get.