AttributeError: partially initialized module 'face_recognition' has no attribute 'face_encodings' - python

I am trying to make face recognition script in python with the help of below given link found on google.
https://www.mygreatlearning.com/blog/face-recognition/
I have installed:
OpenCV
dlib and
face_recognition
libraries.
Also, installed Visual C++ for CMake.
And now I am trying to "extract features from Face" using code given in above link.
While running script, I am getting below error:
Traceback (most recent call last):
File "C:\Users\ajay.arora2\AppData\Local\Programs\Python\Python38-32\extract_features_from_face.py", line 2, in <module>
import face_recognition
File "C:\Users\ajay.arora2\AppData\Local\Programs\Python\Python38-32\face_recognition.py", line 32, in <module>
encodings = face_recognition.face_encodings(rgb)
AttributeError: partially initialized module 'face_recognition' has no attribute 'face_encodings' (most likely due to a circular import)
I have tried re-installing face_recognition module.
Please suggest any workaround.
Thanks in advance.

Most probably you have named your file the same as the library "face_recognition".
Circular import happens when you want to import something from the same file.

Related

AttributeError: partially initialized module 'nmap' has no attribute 'PortScanner' (most likely due to a circular import)

I'm using Windows 11 and VSCode to create a script which will scan the entire network and check the status for every address.
However, when I run the program, I get this error :
Traceback (most recent call last):
File "C:\Users\theog\Desktop\Integration-continue-app-flsak\nmap.py", line 1, in <module>
import nmap
File "C:\Users\theog\Desktop\Integration-continue-app-flsak\nmap.py", line 2, in <module>
nm = nmap.PortScanner()
^^^^^^^^^^^^^^^^
AttributeError: partially initialized module 'nmap' has no attribute 'PortScanner' (most likely due to a circular import)
I've installed the python-nmap module and not the nmap module. I also have the nmap software installed on my computer and included in the system PATH.
Any help would be greatly appreciated,
Thanks!
Fixed it by renaming the file with anything other than nmap.py

calling import _gi causes ImportError _gi.cpython-38-aarch64-linu-gnu.so

I have noticed this error several days ago when overlay icons in nautilus stopped working. I cannot pinpoint any action that might have caused this behaviour as I do remember them working.
I have tried reinstalling using apt and even installing the GObject library locally in my home folder using pip3, but I am getting the same errors.
I am confident the bug is not in the Nextcould integration itself as I am getting the same error with other Nautilus extensions as well.
I have been trying to find a clue on the internet for hours, but I was unable to find even a hint.
Can someone please help? I would be grateful to get the extensions working again (mainly the overlay icons).
These are the errors I am getting when starting Nautilus. I was getting the same errors when using the system-wide version. I tried installing the lib in my home folder to rule out corrupted filesystem.
Initializing nautilus-image-converter extension
ImportError: could not import gobject (error was: ImportError('/home/user/.local/lib/python3.8/site-packages/gi/_gi.cpython-38-aarch64-linux-gnu.so: undefined symbol: PyExc_NotImplementedError'))
Traceback (most recent call last):
File "/usr/share/nautilus-python/extensions/syncstate-Nextcloud.py", line 29, in <module>
from gi.repository import GObject, Nautilus
File "/home/user/.local/lib/python3.8/site-packages/gi/__init__.py", line 40, in <module>
from . import _gi
ImportError: /home/user/.local/lib/python3.8/site-packages/gi/_gi.cpython-38-aarch64-linux-gnu.so: undefined symbol: PyExc_NotImplementedError
Traceback (most recent call last):
File "/usr/share/nautilus-python/extensions/nautilus-hide.py", line 19, in <module>
from gi.repository import Nautilus, GObject
File "/home/user/.local/lib/python3.8/site-packages/gi/__init__.py", line 40, in <module>
from . import _gi
ImportError: /home/user/.local/lib/python3.8/site-packages/gi/_gi.cpython-38-aarch64-linux-gnu.so: undefined symbol: PyExc_NotImplementedError
Traceback (most recent call last):
File "/usr/share/nautilus-python/extensions/nautilus-gsconnect.py", line 10, in <module>
import gi
File "/home/user/.local/lib/python3.8/site-packages/gi/__init__.py", line 40, in <module>
from . import _gi
ImportError: /home/user/.local/lib/python3.8/site-packages/gi/_gi.cpython-38-aarch64-linux-gnu.so: undefined symbol: PyExc_NotImplementedError
I've posted filed a bug report here:
https://bugs.launchpad.net/ubuntu/+source/pygobject/+bug/1980735
Finally,
I managed to fix the issue myself.
I found this bug report describing a similar problem: https://bugzilla.redhat.com/show_bug.cgi?id=1636626 - based on that, I:
uninstalled apt purge nautilus-extension-fma nautilus-image-converter (to make sure none of the extensions are calling Python2.
after this step, I noticed another error (that previously did not appear):
(org.gnome.Nautilus:15062): Nautilus-Python-WARNING **: 05:32:20.623: g_module_open libpython failed: /usr/lib/libpython3.8.so.1.0: cannot open shared object file: No such file or directory
I fixed the error by: sudo ln -s /usr/lib/aarch64-linux-gnu/libpython3.8.so.1.0 /usr/lib/

ModuleNotFoundError: No module named 'github'

trying to import github (PyGithub) but it keeps giving the same error, even though the lib is fully installed.
Code:
from github import Github
Output:
Traceback (most recent call last):
File "...path", line 1, in <module>
from github import Github
ModuleNotFoundError: No module named 'github'
Anyone know how to fix this issue?
This will install the package.
pip3 install PyGithub
If you're getting the same error that could be due to circular imports. Rename if you have any .py files named "github.py" in your work folder.

Music21 AttributeError: module 'importlib' has no attribute 'util'

I'm trying to get started using music21 in python. I've imported the package into PyCharm but when I use the line:
import music21
at the start of my file, it gives me:
Traceback (most recent call last):
File "C:/Users/Miles/Documents/Miles/Uni/Coding/Music21/Start.py", line 1, in <module>
import music21
File "C:\Users\Miles\Documents\Miles\Uni\Coding\Music21\venv\Environment\lib\site-packages\music21\__init__.py", line 169, in <module>
from music21 import base # noqa: E402
File "C:\Users\Miles\Documents\Miles\Uni\Coding\Music21\venv\Environment\lib\site-packages\music21\base.py", line 119, in <module>
loader = importlib.util.find_spec(modName)
AttributeError: module 'importlib' has no attribute 'util'
It works fine when I try to run it from the python console, and I'm using python 3.7 and music21 version 6.5 which should be compatible so not sure where I'm going wrong.
Fixed in the unreleased version (current development branch on GitHub).
See this issue and linked PR:
https://github.com/cuthbertLab/music21/issues/750
Since you are saying it works for you in python console, I suggest installing music21 package in PyCharm. Refer the following document for installing packages in PyCharm.
https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html

Python igraph import error on Windows

I've installed igraph form .whl file using pip install. When I was trying to test the correctness of installation
import igraph.test
igraph.test.test()
I got this error:
Traceback (most recent call last):
File "D:/Nauka/Praca-inzynierska/Barabasi-Albert.py", line 4, in <module>
import igraph.test
File "D:\Programy\Python 3.5\lib\site-packages\igraph\__init__.py", line 34, in <module>
from igraph._igraph import *
ImportError: No module named 'igraph._igraph'
(the same error pops out if I'm trying to import igraph not igraph.test).
I've tried adding path (I don't know if this is rigth):
import sys
sys.path.append ("D:/Programy/Python 3.5/Lib/site-packages/igraph")
but it didn't work.
One thing I discovered is that if I delete "__init__" file from igraph folder I can import igraph without error, but it doesn't work for igraph.test.
If it's relevant I have Python 2.7 installed on my machine alongside Python 3.5.
Thank you in advance for any help.

Categories

Resources