AttributeError: 'module' object has no attribute
You have mutual top-level imports, which is almost always a bad idea.
If you really must have mutual imports in Python, the way to do it is to import them within a function:
# In b.py:
def cause_a_to_do_something():
import a
a.do_something()
Now a.py can safely do import b
without causing problems.
(At first glance it might appear that cause_a_to_do_something()
would be hugely inefficient because it does an import
every time you call it, but in fact the import work only gets done the first time. The second and subsequent times you import a module, it's a quick operation.)
Python module 'datetime' has no attribute 'datetime_CAPI'
I found the problem, it was a Python compilation issue. I used the following commands to compile Python and the problem was solved.
CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ AR=arm-linux-gnueabihf-ar \
RANLIB=arm-linux-gnueabihf-ranlib \
./configure --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf \
--build=x86_64-linux-gnu --prefix=$HOME/python3.8.10 \
--disable-ipv6 ac_cv_file__dev_ptmx=no ac_cv_file__dev_ptc=no \
ac_cv_have_long_long_format=yes --enable-shared
make HOSTPYTHON=$HOME/python3.8.10 \
BLDSHARED="arm-linux-gnueabihf-gcc -shared" CROSS-COMPILE=arm-linux-gnueabihf- \
CROSS_COMPILE_TARGET=yes HOSTARCH=arm-linux BUILDARCH=arm-linux-gnueabihf
make altinstall HOSTPYTHON=$HOME/python3.8.10 \
BLDSHARED="arm-linux-gnueabihf-gcc -shared" CROSS-COMPILE=arm-linux-gnueabihf- \
CROSS_COMPILE_TARGET=yes HOSTARCH=arm-linux BUILDARCH=arm-linux-gnueabihf \
prefix=$HOME/python3.8.10/_install
While importing train_test_split from from sklearn.model_selection, why am I getting the error AttributeError: module 'attr' has no attribute 's' ?
This will solve your problem
Type these commands in terminal or in a notebook
pip uninstall attr
pip install attrs
Related Topics
Printing Simple Diamond Pattern in Python
Convert a Standard Python Key Value Dictionary List to Pyspark Data Frame
Importerror: No Module Named Bs4 (Beautifulsoup)
Python Number With 1000 Separator
How to Find the Maximum Consecutive Occurrences of a Number in Python
Get Rid of Columns With Null Value in Json Output
Using Pyserial to Send Binary Data
Tf.Data.Dataset: How to Get the Dataset Size (Number of Elements in an Epoch)
Install Utils Package in Python Facing With Error Package Not Found
Sqlalchemy, Prevent Duplicate Rows
How to Delete a Character in an Item in a List (Python)
Permissionerror: [Errno 13] Permission Denied Flask.Run()
Python Flask Threaded True Not Working
How to Close an Internet Tab With Cmd/Python
Make Alternate Letters Capital
How to Limit Iterations of a Loop in Python