-
Notifications
You must be signed in to change notification settings - Fork 63
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
ImportError: No module named lxml on OS X #51
Comments
I'll enable os x build this weekend. In the meantime, what Ansible version are using? Did you install lxml with EDIT: PS -- no go on enabling os x build. travis-ci/travis-ci#4729 & https://travis-ci.org/cmprescott/ansible-xml/builds/117309833 |
But there is something strange, executing the tests works on my machine but executing another very simple playbook fails complaining about the missing lxml.
Error
|
Osx can have weeeird library logic sometimes. Because you said one method works, but a full test doesn't, this may be related to how the specific python binary is called. This may be an edge case if @ssbarnea has an unusual python package/library configuration. I know on my osx box i get issues because i have several different python versions installed. Id double check the module writing docs for any specific notes apropos the she-bang. This module explicitly says To the OP, if you run
|
Here is the issue with OS X, because is too dangerous to do anything with the OS provided python, people are installing a local copy using brew, which resides in Assuming a hardcoded path for python interpreter is clearly a big mistake, the correct approach is to point to the default one using one of these shebang lines:
Please note that the first one should be used only by software that works on both pyhon2 and python3, ansible is supposed to use |
Here is a funny fact, it seems that on my machine
This tells me that ansible installer makes a decision to point there. Good part is that's a symlink to brew version of python, one identical with the one inside /usr/local/bin/python2.7. So which was the module that had the wrong path in the shebang line?
Yes, the native python does not have lxml and it should never get it, the problem is not the python itself, the problem is that ansible ends up trying to use that one instead of default one (env/which approach) |
@ssbarnea thank you for confirming that using
If that succeeds, then see what happens if you do this:
If those fail, I advise you attempt to install lxml using the package manager that you installed ansible with. This reference may be useful Here's some other information I was able to figure out which may be helpful (or just good to know): I just cloned the
However, note the following quote from the docs http://docs.ansible.com/ansible/faq.html#how-do-i-handle-python-pathing-not-having-a-python-2-x-in-usr-bin-python-on-a-remote-machine
|
I was able to bypass the problem by adding this to the playbook:
As you can guess, this will tell ansible to use python2 executable from PATH, which will solve the missing I am sure that this is not a problem of the My impression is that's an ansible deployment decision issue, the decision of replacing the shebang with Now, I think that it would be in our interest to resolve this bad user experience, so people would be able to use xml module without having to spend hours wondering why it does not work on some machines. |
- Issue #51 lxml problems on OS X - Only apt-get on linux
- Issue #51 lxml problems on OS X - Only apt-get on linux
Closing as won't fix. However, keep in mind I have a rainy day project to create an ansible-role-lxml. Hopefully, that solves a lot of the headaches associated with installing the dependency on the controller. |
I am ok with this, meanwhile I changed jobs and I did not need this anymore. I think that ideally Still, I am fully aware that I will need XML support again and I would like to see XML as part of ansible core distribution. If you also support the idea you should vote/comment on ansible/ansible-modules-core#4112 I am not sure if this could be of you to you but at least in one case I was able to remove the need of lxml by replacing it with defusedxml. BTW, Support for Python 3 in Ansible is almost here, the latest version has experiment support for it. |
Please enable OS X tests on travis because it seems kinda impossible to make the xml module to work on it, even when this module is installed and I am running the task against localhost.
Have a look here on how to enable it, is two lines of code https://github.com/pycontribs/tendo/blob/master/.travis.yml
The text was updated successfully, but these errors were encountered: