ImportError: cannot import name 'app_settings' from 'leaflet' - python

I was running django project in Anaconda prompt and I got the following error:
File "C:\Users\hp\geoportal_geodjango\mysite\polls\admin.py", line 4, in <module>
from leaflet.admin import LeafletGeoAdmin
File "C:\ProgramData\Anaconda3\lib\site-packages\leaflet\admin.py", line 17, in <module>
from .forms.widgets import LeafletWidget
File "C:\ProgramData\Anaconda3\lib\site-packages\leaflet\forms\widgets.py", line 15, in <module>
from leaflet import app_settings, PLUGINS, PLUGIN_FORMS
ImportError: cannot import name 'app_settings' from 'leaflet' (C:\ProgramData\Anaconda3\lib\site-packages\leaflet\__init__.py)
I tried different leaflet versions.

just use pip install django-leaflet==0.19.0 and it will uninstall the Django-leaflet you installed and install v 0.19.0

Even if you have v0.19 installed, uninstall it and the install it again

Related

ModuleNotFoundError: No module named 'pyarrow.lib'

This is the full error message.
Traceback (most recent call last):
File "C:\Users\adi\OneDrive\Desktop\Python310\machine learning project.py", line 3, in <module>
import streamlit as st
File "C:\Users\adi\OneDrive\Desktop\Python310\lib\site-packages\streamlit\__init__.py", line 70, in <module>
from streamlit.delta_generator import DeltaGenerator as _DeltaGenerator
File "C:\Users\adi\OneDrive\Desktop\Python310\lib\site-packages\streamlit\delta_generator.py", line 19, in <module>
from streamlit import cursor, caching
File "C:\Users\adi\OneDrive\Desktop\Python310\lib\site-packages\streamlit\cursor.py", line 18, in <module>
from streamlit.scriptrunner import get_script_run_ctx
File "C:\Users\adi\OneDrive\Desktop\Python310\lib\site-packages\streamlit\scriptrunner\__init__.py", line 16, in <module>
from .script_runner import (
File "C:\Users\adi\OneDrive\Desktop\Python310\lib\site-packages\streamlit\scriptrunner\script_runner.py", line 35, in <module>
from streamlit.state import (
File "C:\Users\adi\OneDrive\Desktop\Python310\lib\site-packages\streamlit\state\__init__.py", line 27, in <module>
from .session_state_proxy import (
File "C:\Users\adi\OneDrive\Desktop\Python310\lib\site-packages\streamlit\state\session_state_proxy.py", line 24, in <module>
from streamlit.type_util import Key
File "C:\Users\adi\OneDrive\Desktop\Python310\lib\site-packages\streamlit\type_util.py", line 22, in <module>
import pyarrow as pa
File "C:\Users\adi\OneDrive\Desktop\Python310\lib\site-packages\pyarrow\__init__.py", line 65, in <module>
import pyarrow.lib as _lib
I am working with streamlit for a project but can't work out this problem.
I have tried uninstalling and reinstalling streamlit but that did'nt help.
i using python 3.8
Uninstalling and re-installing solved the issue for me:
pip uninstall pyarrow
pip install pyarrow
I think I messed things up by changing the Python version in my Conda environment.
You need to install pyarrow
python3 -m pip install pyarrow
Check these 2 things(worked for me) -
1-If you have changed your python version recently, uninstall all libraries then install.(can be done easily by pip uninstall -r requirements.txt -y & then pip install -r requirements.txt -y
2- If you have installed pyarrow in a different environment.

ModuleNotFoundError: No module named 'pyasn1'

File "D:\Documents\my_project\firebase_login.py", line 1, in <module>
from pyrebase import pyrebase
File "D:\Documents\Python_projects\Test_kivy\venv\lib\site-packages\pyrebase\__init__.py", line 1, in <module>
from .pyrebase import initialize_app
File "D:\Documents\Python_projects\Test_kivy\venv\lib\site-packages\pyrebase\pyrebase.py", line 17, in <module>
from oauth2client.service_account import ServiceAccountCredentials
File "D:\Documents\Python_projects\Test_kivy\venv\lib\site-packages\oauth2client\service_account.py", line 26, in <module>
from oauth2client import crypt
File "D:\Documents\Python_projects\Test_kivy\venv\lib\site-packages\oauth2client\crypt.py", line 23, in <module>
from oauth2client import _pure_python_crypt
File "D:\Documents\Python_projects\Test_kivy\venv\lib\site-packages\oauth2client\_pure_python_crypt.py", line 22, in <module>
from pyasn1.codec.der import decoder
ModuleNotFoundError: No module named 'pyasn1'
Process finished with exit code 1
My code was working like a charm yesterday, today I'm not able to launch it due to pyrebase crashing.
I have this error coming from a PyCharm project.
Pyrebase4: v4.5.0 https://github.com/nhorvath/Pyrebase4
I had the same problem, i solved updating pip.
I also found a similar import issue open on github.
python -m ensurepip
python get-pip.py
pip install awscli --ignore-installed six
ModuleNotFoundError: No module named 'pyasn1_modules'
pip install pyasn1_modules
ModuleNotFoundError: No module named 'google.protobuf'
pip install protobuf

Jupiter notebook run error: AttributeError: module 'importlib_metadata' has no attribute 'version'

Originally, Jupyter notebook was running well without any problems.
But after installing tensorflow and keras today, it doesn't work.
Error message:
Traceback (most recent call last):
File "C:\Anaconda3\Scripts\jupyter-notebook-script.py", line 6, in <module>
from notebook.notebookapp import main
File "C:\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 85, in <module>
from .services.contents.manager import ContentsManager
File "C:\Anaconda3\lib\site-packages\notebook\services\contents\manager.py", line 17, in <module>
from nbformat import sign, validate as validate_nb, ValidationError
File "C:\Anaconda3\lib\site-packages\nbformat\__init__.py", line 32, in <module>
from .validator import validate, ValidationError
File "C:\Anaconda3\lib\site-packages\nbformat\validator.py", line 12, in <module>
from .json_compat import get_current_validator, ValidationError
File "C:\Anaconda3\lib\site-packages\nbformat\json_compat.py", line 10, in <module>
import jsonschema
File "C:\Anaconda3\lib\site-packages\jsonschema\__init__.py", line 34, in <module>
__version__ = metadata.version("jsonschema")
AttributeError: module 'importlib_metadata' has no attribute 'version'
There is a problem with your importlib_metadata package, you can try uninstall it first and then forcing out a new installation with the following commands:
pip uninstall importlib_metadata
pip install importlib_metadata --force-reinstall
It worked for me.
This is a problem with the Anaconda version upgrade.
You can solve this with the following command that worked for me.
conda install -c conda-forge importlib_metadata
For me, the same error happened after VSCode proposed me to install a tensorboard plugin and I pressed yes. (MacOS 11.4, Conda 4.10.3)
It appears that it introduced some kind of version mismatch for multiple packages in the environment.
The following fixed the problem:
conda update --all

ImportError: cannot import name 'registry' from 'pandas.core.dtypes.base'

I just did a conda install of a few packages to follow a tutorial, and now I can't even import pandas.
I installed these:
fake-factory==0.7.2
Faker==0.7.3
pytz==2016.7
tzlocal==1.3.0
And now I get this:
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\__init__.py", line 42, in <module>
from pandas.core.api import *
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\api.py", line 7, in <module>
from pandas.core.arrays.integer import (
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\arrays\__init__.py", line 2, in <module>
from .base import (ExtensionArray, # noqa
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\arrays\base.py", line 21, in <module>
from pandas.core import ops
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\ops\__init__.py", line 21, in <module>
from pandas.core.construction import extract_array
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\construction.py", line 18, in <module>
from pandas.core.dtypes.base import ExtensionDtype, registry
ImportError: cannot import name 'registry' from 'pandas.core.dtypes.base' (C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\dtypes\base.py)
I tried doing a conda update pandas, but to no avail.
I also just installed luigi, not quite sure when it broke as I installed all the additional packages in one go.
Updated version of pandas package using pip3
try this in python3
pip3 install --upgrade pandas
Try updating pandas package in Anaconda:
conda install pandas=1.1.4
If no luck, try updating all packages:
conda update --all
Worked in my case.

ImportError: No module named 'nose'

I tried to help('modules') and there was no nose module.
I even tried pip install nose, sudo pip install nose, and etc..
When ever I tried to install nose with command line, it will throw out
SyntaxError: invalid syntax.
Traceback (most recent call last):
File "C:\Python34\plot_cluster_iris.py", line 31, in <module>
from sklearn.cluster import KMeans
File "C:\Python34\lib\site-packages\sklearn\cluster\__init__.py", line 6, in <module>
from .spectral import spectral_clustering, SpectralClustering
File "C:\Python34\lib\site-packages\sklearn\cluster\spectral.py", line 13, in <module>
from ..utils import check_random_state, as_float_array
File "C:\Python34\lib\site-packages\sklearn\utils\__init__.py", line 11, in <module>
from .validation import (as_float_array, check_arrays, safe_asarray,
File "C:\Python34\lib\site-packages\sklearn\utils\validation.py", line 17, in <module>
from .fixes import safe_copy
File "C:\Python34\lib\site-packages\sklearn\utils\fixes.py", line 18, in <module>
from .testing import ignore_warnings
File "C:\Python34\lib\site-packages\sklearn\utils\testing.py", line 36, in <module>
from nose.tools import assert_equal
What should I do?
I think your pip3 and python3 versions are mismatched, possibly due to multiple versions of Python 3 installed.
Run pip3 --version to find the exact Python version that pip3 is associated with and the location of site-packages directory.
Then, run python3 and look at the location of site-packages using:
import site
site.getsitepackages()
If you see different directory locations then that's your problem - multiple versions of Python 3. If it is indeed the problem, remove both the versions, re-install the correct one and then install your packages.
I hope this helps!

Categories