Checking Ansible version(ansible --version) but getting following error - python

And Jinja2 modules Requirement already satisfied
Traceback (most recent call last):
File "/usr/bin/ansible", line 60, in <module>
import ansible.constants as C
File "/usr/lib/python3.7/site-packages/ansible/constants.py", line 12, in <module>
from jinja2 import Template
ModuleNotFoundError: No module named 'jinja2'

This looks like a broken install. A dependency is missing. Try:
pip3 install jinja2
This is not really supposed to happen when you install ansible "normally". If the above does not fix your problem, I suggest you reinstall ansible from scratch on your system

Related

Can't import pymatgen.core "No module named 'pymatgen.core'"

I've used pip install pymatgen with Python 3.9.1 on Windows 10 to install pymatgen, but I'm getting the following error:
Traceback (most recent call last):
File "D:\code\pymatgen\pymatgen.py", line 1, in <module>
import pymatgen.core as mg
File "D:\code\pymatgen\pymatgen.py", line 1, in <module>
import pymatgen.core as mg
ModuleNotFoundError: No module named 'pymatgen.core'; 'pymatgen' is not a package
I have also tried to install the previous 2 versions but still getting the same error though I can already see it in the pip list
pymatgen 2022.3.22
What am I missing?
Maybe try using conda ? if this doesn't work then there is definitely some dependencies issue
https://pymatgen.org/installation.html

ImportError: No module named api_core.exceptions

I wanted to run a google.cloud.storage dependency to my project so I tried to install this dependency with
sudo pip install --upgrade google-api-python-client
Running the above command, we installed all the required packages in the apache airflow dist-packages directory ex:- /usr/local/python2.7/dist-packages/
When i imported libraries into my project using the below code.
from airflow.contrib.operators.mysql_to_gcs import MySqlToGoogleCloudStorageOperator
running the project on Python, i am getting the error ImportError: No module named api_core.exceptions
here is the trace
#python mysql_to_gcs.py
[2019-04-30 06:45:09,668] {settings.py:182} INFO - settings.configure_orm(): Using pool settings. pool_size=5, pool_recycle=1800, pid=15440
Traceback (most recent call last):
File "mysql_to_gcs.py", line 2, in <module>
from airflow.contrib.operators.mysql_to_gcs import MySqlToGoogleCloudStorageOperator
File "/usr/local/lib/python2.7/dist-packages/airflow/contrib/operators/mysql_to_gcs.py", line 25, in <module>
from airflow.contrib.hooks.gcs_hook import GoogleCloudStorageHook
File "/usr/local/lib/python2.7/dist-packages/airflow/contrib/hooks/gcs_hook.py", line 25, in <module>
from airflow.contrib.hooks.gcp_api_base_hook import GoogleCloudBaseHook
File "/usr/local/lib/python2.7/dist-packages/airflow/contrib/hooks/gcp_api_base_hook.py", line 30, in <module>
from google.api_core.exceptions import GoogleAPICallError, AlreadyExists, RetryError
ImportError: No module named api_core.exceptions
Instead of --upgrade google-api-python-client Just reinstall api-core using
pip install dialogflow
Upgrade has some weird problems which does not update api-core.

twisted module not found error from Python Flasky

I am having trouble in running a flask file that is manager.py on Windows 10. Although I installed requirements, it still aborts an import error.What's funny is the errors are different in PyCharm and cmd. And I activated the same virtual environment.I will appreciate it if someone can help me!
In PyCharm:
Traceback (most recent call last):
File "C:/Users/Administrator/Desktop/Online-serial-debugging/manage.py", line 6, in <module>
from app import create_app
File "C:\Users\Administrator\Desktop\Online-serial-debugging\app\__init__.py", line 2, in <module>
from flask.ext.twisted import twisted
File "C:\Users\Administrator\Desktop\online\Online-serial-debugging\enve\lib\site-packages\flask\exthook.py", line 87, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named flask.ext.twisted.twisted
Process finished with exit code 1
In CMD:
(enve) C:\Users\Administrator\Desktop\online\Online-serial-debugging>python manage.py
Traceback (most recent call last):
File "manage.py", line 5, in <module>
from flask.ext.script import Manager
ImportError: No module named flask.ext.script
Here are my requirments.txt:
construct==2.5.2
dominate==2.1.16
Flask==0.10.1
Flask-Bootstrap==3.3.5.3
Flask-Moment==0.5.0
Flask-Twisted==0.1.1
Flask-Script==2.0.5
itsdangerous==0.24
Jinja2==2.7.3
MarkupSafe==0.23
observable==0.1.0
pyserial==2.7
six==1.10.0
Twisted==15.4.0
txsockjs==1.2.2
pypiwin32
Werkzeug==0.10.4
zope.interface==4.1.2
Please fix your import statement as follows, and could you try?
from flask_script import Manager
EDIT
Sorry, even using flask.ext.{}, it seems still works.
If you run the following command, what come back?
pip install Flask-Script==2.0.5
It means that 'Flask-Script' was not installed, check your 'pip freeze'.
Was there any error when installing the requirements? If so, try to identify the issue.
Try installing it:
$ pip install Flask-Script
OK. The problem is solved.orz. My command line is :
python manage.py
Actually, I used the Python interpreter in system path by mistake.And I run this command :
./enve/Scripts/python.exe manage.py
There are no import errors again, thank you who answered me still.

ImportError: No module named django_auth_ldap

I can't seem to get python ldap libraries to work properly with Django:
>>> from django_auth_ldap import *
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: No module named django_auth_ldap
I'm running Ubuntu v14.
This is what a pip freeze looks like on my working environment:
Django==1.9.4
django-auth-ldap==1.2.7
django-filter==0.13.0
djangorestframework==3.3.3
Markdown==2.6.5
pyasn1==0.1.9
pyldap==2.4.25.1
python3-ldap==0.9.8.4
(I installed ldap for python3 as well to do a sanity check)
But as I go through all the guides here, they all seem to point to the same libraries I already have except for "pip install python-ldap".
When I try to do:
pip install python-ldap
I just get the following result:
Collecting python-ldap
Using cached python-ldap-2.4.25.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-0c5p7fkj/python-ldap/setup.py", line 53
print name + ': ' + cfg.get('_ldap', name)
^
SyntaxError: invalid syntax
----------------------------------------
Does anyone know what are the best steps I should take to get around this issue to get the library working?
I've tried doing a wget for
https://pypi.python.org/pypi/python-ldap
And I extracted the files and simply used
python setup.py install to the tar ball, but to no avail.
Any suggestions?
Found the solution from this page:
https://www.howtoinstall.co/en/ubuntu/precise/universe/python-django-auth-ldap/
The following command seems to have done the trick:
apt-get install python-django-auth-ldap

ATpy ImportError: No module named astropy.io

I tried to get atpy on python 2.7. I downloaded ATpy0.9.6 from
https://pypi.python.org/pypi/ATpy/0.9.6
then tar it, and run:
cd ATpy0.9.6
sudo python setup.py install
things seemed to work well.
But when I tried to import atpy on python, I got always this error message:
ImportError: No module named astropy.io
More precisely,
>>> import atpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/atpy/__init__.py", line 1, in <module>
from .basetable import Table, TableSet, VectorException
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/atpy/basetable.py", line 15, in <module>
from . import registry
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/atpy/registry.py", line 164, in <module>
from . import fitstable
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/atpy/fitstable.py", line 8, in <module>
from astropy.io import fits
ImportError: No module named astropy.io
>>>
Could anyone help me to figure out the problem?
Perhaps the 'atpy' package depends on another package called 'astropy.io' that you are missing? Yes here it is https://astropy.readthedocs.org/en/v0.1/index.html
It happens that downloading the tar balls from pypi.python.org is the wrong way to install Python packages. The right way (though the Python docs explain poorly), is to run a command like
pip install atpy
This command will install your package and all its dependencies.
If the command pip is missing, you have to install it, which is ironically really complicated.
In my case the solution was to install astropy
pip install --no-deps astropy

Categories

Resources