Good afternoon, I have a pymongo module that I installed via pip3 and now I am trying to use it
- name: Create role for pbm
community.mongodb.mongodb_shell:
login_host: 10.0.44.40
eval: 'db.getSiblingDB ("admin"). createRole ({"role": "pbmAnyAction", "privileges": [{"resource": {"anyResource": true}, "actions": ["anyAction"] }], "roles": []}); '
vars:
ansible_python_interpreter: / usr / bin / python3
ignore_errors: yes
when: groups.mongodb.index (inventory_hostname) == 0
and everything works well on my local vagrant vm, but when I run it on the production vm, an error appears
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No module named pymongo.errors
fatal: [mongodb-01]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (pymongo) on superproduction-mongo-01's Python / usr / bin / python. Please read module documentation and install in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter "}
OS versions for vagrant and production are the same (centos 7)
python3 version output and import pymongo.errors from production vm
python3
Python 3.6.8 (default, Nov 16 2020, 16:55:22)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymongo.errors
>>>
from vagrant vm
python3
Python 3.6.8 (default, Nov 16 2020, 16:55:22)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymongo.errors
>>>
as you can see output the same
worked even though I didn't do anything
Related
System: macOS Mojave 10.14.6
Python3: Python 3.7.4
My emacs config ( according to https://github.com/hlissner/doom-emacs/issues/212 );
(setq python-shell-interpreter "/usr/local/bin/python3" flycheck-python-pycompile-executable "/usr/local/bin/python3")
Trying to use run-python in emacs doom. Having:
Python 3.7.4 (v3.7.4:e09359112e, Jul 8 2019, 14:54:52)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> python.el: native completion setup failed, <class 'ModuleNotFoundError'>: No module named 'readline'
Warning (python): Your ‘python-shell-interpreter’ doesn’t seem to support readline, yet ‘python-shell-completion-native-enable’ was t and "python3" is not part of the ‘python-shell-completion-native-disabled-interpreters’ list. Native completions have been disabled locally.
import readline works perfectly in python3 in terminal.
Default python 2.7.10 doesn't work too (no my emacs config).
Python 2.7.10 (default, Feb 22 2019, 21:55:15)
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import codecs, os;__pyfile = codecs.open('''/var/folders/y3/g447wqxd4l97rk7th2fszwb00000gn/T/pyQo4DAR''', encoding='''utf-8''');__code = __pyfile.read().encode('''utf-8''');__pyfile.close();os.remove('''/var/folders/y3/g447wqxd4l97rk7th2fszwb00000gn/T/pyQo4DAR''');exec(compile(__code, '''/var/folders/y3/g447wqxd4l97rk7th2fszwb00000gn/T/pyQo4DAR''', 'exec'));
python.el: native completion setup failed, <type 'exceptions.Exception'>: libedit based readline is known not to work,
see etc/PROBLEMS under "In Inferior Python mode, input is echoed".
>>>
How to make emacs doom run python3 right?
Can anyone help me understand why python's logging module creates a StreamHandler on import, but only on some distributions? weird.. (note: happens on any python3)
On Mac
Python 3.5.6 (default, Dec 19 2019, 14:59:39)
[GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.33.8)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import logging
>>> logging.getLogger().handlers
[<logging.StreamHandler object at 0x108fc2630>]
Linux:
Python 3.7.4 (default, Jan 3 2020, 19:27:19)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import logging
>>> logging.getLogger().handlers
[]
>>>
I can't seem to find any explanation about this behavior difference!
EDIT:
A bit more investigation suggests that some module installed in the virtualenv is causing this behavior mismatch. I created a fresh one with the same python interpreter and no handler gets made. I'm trying to investigate which module seems to cause this.
This isn't actually a platform difference, but was a result of an installed library.
I filed the issue upstream https://github.com/stuaxo/vext/issues/63
I want to
import pybel
in jupyter-notebook and it says
The kernel appears to have died. It will restart automatically.
When I use it in python3, I get:
Python 3.6.6 | packaged by conda-forge | (default, Jul 26 2018, 09:53:17)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pybel
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_M_construct null not valid
Aborted (core dumped)
Installing using pip3 instead of conda
pip3 install pybel
works
I am trying to start a vagrant vm and provision it using its ansible provisioner;
config.vm.provision "ansible" do |ansible|
ansible.limit = "all"
ansible.compatibility_mode = "2.0"
ansible.playbook = "ansible/install.yml"
end
the box is ubuntu/xenial64
Provisioning fails as follows:
==> default: Running provisioner: ansible...
default: Running ansible-playbook...
ImportError: No module named site
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
Host is Ubuntu 16.04.05 with ansible 2.7.0
I even tried to run a shell provisioner that installs python-minimal on the guest before executing ansible, but with no luck.
edit: in the mean time, on my controller:
/home/pkara/Desktop
$ python
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import site
>>>
/home/pkara/Desktop
$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import site
>>>
I am not able to run python manage.py shell, I am getting the following exception:
[root#dd dase]# python manage.py shell
Error: cannot import name six
But six is installed on the server:
[root#dd dase]# python
Python 2.6.6 (r266:84292, Jun 18 2012, 14:18:47)
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import six
>>> six.__version__
'1.9.0'
Django Version:
[root#dd dase]# django-admin --version
1.2.7
Nothing in traceback:
[root#dd dase]# python manage.py shell --traceback
Error: cannot import name six
Could be a package you have installed that's trying to use django.utils.six which became available in 1.4.2 (No module named six). Definitely upgrade your django version as given above.