Error: module' object has no attribute 'symlink
Question:
I am installing Ansible using Python2.7 but I am having an error upon installation.
Here are my steps and I am using Windows 10 64 bit
-
Install Python 2.7
-
Go to command line and go to directory C:Python27Scripts
-
Type command pip install ansible
Error
Command "c:python27python.exe -u -c "import setuptools, tokenize;__file__='c:\users\dave\appdata\local\temp\pip-build-_tn3so\ansible\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" install --record c:usersdaveappdatalocaltemppip-ltscus-recordinstall-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:usersdaveappdatalocaltemppip-build-_tn3soansible
Answers:
As is clearly stated in the fine manual, Windows is not supported for use as a control machine. Even if you got it to install, the next problem you’d have is trying to convince it to use a sane ssh client, of which PuTTY is not one.
I am sure you can use the Windows Subsystem for Linux to gain access to a reasonable operating system inside the unreasonable one
import os
import os.path
import platform
import subprocess
def _symlink(source, link_name):
# If we are already in a version of python that supports symlinks then
# just use the os module, otherwise fall back on ctypes. It requires
# administrator privileges to run or the correct group policy to be set.
# This implementation is taken from
# http://stackoverflow.com/questions/6260149/os-symlink-support-in-windows
if callable(getattr(os, "symlink", None)):
os.symlink(source, link_name)
elif "Windows-10" in platform.platform():
# Starting with Windows 10 Insiders build 14972, symlinks can be
# created without needing to elevate the console as administrator.
# https://blogs.windows.com/windowsdeveloper/2016/12/02/symlinks-windows-10/#joC5tFKhdXs2gGml.97
subprocess.check_output("mklink %s %s" % (link_name, source), shell=True)
else:
import ctypes
csl = ctypes.windll.kernel32.CreateSymbolicLinkW
csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)
csl.restype = ctypes.c_ubyte
flags = 1 if os.path.isdir(source) else 0
if csl(link_name, source, flags) == 0:
raise ctypes.WinError()
I am installing Ansible using Python2.7 but I am having an error upon installation.
Here are my steps and I am using Windows 10 64 bit
-
Install Python 2.7
-
Go to command line and go to directory C:Python27Scripts
-
Type command pip install ansible
Error
Command "c:python27python.exe -u -c "import setuptools, tokenize;__file__='c:\users\dave\appdata\local\temp\pip-build-_tn3so\ansible\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file__, 'exec'))" install --record c:usersdaveappdatalocaltemppip-ltscus-recordinstall-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:usersdaveappdatalocaltemppip-build-_tn3soansible
As is clearly stated in the fine manual, Windows is not supported for use as a control machine. Even if you got it to install, the next problem you’d have is trying to convince it to use a sane ssh client, of which PuTTY is not one.
I am sure you can use the Windows Subsystem for Linux to gain access to a reasonable operating system inside the unreasonable one
import os
import os.path
import platform
import subprocess
def _symlink(source, link_name):
# If we are already in a version of python that supports symlinks then
# just use the os module, otherwise fall back on ctypes. It requires
# administrator privileges to run or the correct group policy to be set.
# This implementation is taken from
# http://stackoverflow.com/questions/6260149/os-symlink-support-in-windows
if callable(getattr(os, "symlink", None)):
os.symlink(source, link_name)
elif "Windows-10" in platform.platform():
# Starting with Windows 10 Insiders build 14972, symlinks can be
# created without needing to elevate the console as administrator.
# https://blogs.windows.com/windowsdeveloper/2016/12/02/symlinks-windows-10/#joC5tFKhdXs2gGml.97
subprocess.check_output("mklink %s %s" % (link_name, source), shell=True)
else:
import ctypes
csl = ctypes.windll.kernel32.CreateSymbolicLinkW
csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)
csl.restype = ctypes.c_ubyte
flags = 1 if os.path.isdir(source) else 0
if csl(link_name, source, flags) == 0:
raise ctypes.WinError()