AttributeError: module 'ee' has no attribute 'Reducer' - jupyter-lab

I'm learning GEE recently with accessing VPN but met error as show below:
#######################################################
import ee
import geemap
import os
geemap.set_proxy(port=7890)
os.environ['HTTP_PROXY'] = 'http://127.0.0.1:7890'
os.environ['HTTPS_PROXY'] = 'http://127.0.0.1:7890'
Map = geemap.Map()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In [5], line 7
5 os.environ['HTTP_PROXY'] = 'http://127.0.0.1:7890'
6 os.environ['HTTPS_PROXY'] = 'http://127.0.0.1:7890'
----> 7 Map = geemap.Map()
File ~\anaconda3\envs\gee\lib\site-packages\geemap\geemap.py:173, in
Map.__init__(self, **kwargs)
171 self.roi_end = False
172 if kwargs["ee_initialize"]:
--> 173 self.roi_reducer = ee.Reducer.mean()
174 self.roi_reducer_scale = None
176 # List for storing pixel values and locations based on user-drawn
geometries.
AttributeError: module 'ee' has no attribute 'Reducer'
##############################################################
I checked too many answers through forum but nothing work. Is there anyone who knows the reason? really appreciate it!

Related

CompletedSubTask' object has no attribute 'aspect_representation

I am working on an aspect based sentiment.
I am just trying to get the code to work which is in example on the module blog.
but i have this error:
html = absa.probing.explain(slack)
display(html)
AttributeError Traceback (most recent call last)
<ipython-input-20-98b6fe874b12> in <module>
----> 1 html = absa.probing.explain(slack)
2 display(html)
~/Library/Python/3.8/lib/python/site-packages/aspect_based_sentiment_analysis/probing/plots.py in explain(example)
47
48 def explain(example: PredictedExample):
---> 49 aspect = example.aspect_representation
50 texts = [f'Words connected with the "{example.aspect}" aspect: <br>']
51 texts.extend(highlight_sequence(aspect.tokens, aspect.look_at))
AttributeError: 'CompletedSubTask' object has no attribute 'aspect_representation'
Here more : https://pypi.org/project/aspect-based-sentiment-analysis/

module 'pandas' has no attribute 'series'

i got this error while running this code
import numpy as np
import pandas as pd
labels = ['a','b','c']
my_list = [10,20,30]
arr = np.array(my_list)
d = {'a':10,'b':20,'c':30}
pd.series(data = my_list)
full error msg
AttributeError Traceback (most recent call last)
<ipython-input-10-494578c29940> in <module>
----> 1 pd.series(data = my_list)
F:\New folder (8)\lib\site-packages\pandas\__init__.py in __getattr__(name)
260 return _SparseArray
261
--> 262 raise AttributeError(f"module 'pandas' has no attribute '{name}'")
263
264
AttributeError: module 'pandas' has no attribute 'series'
Series is a Pandas class, so it starts with a capital letter. The below should work.
pd.Series(data = my_list)

Openpyxl version 2.5.11 issue

I updated yesterday with Openpyxl library to version 2.5.11. Now, when i simply open an excel workbook (it's a xlsx file without macros), I get the following strange error message that I didn't have when I was opening the exact same file yesterday before I updated the library:
Code:
tips = r"NTipsPerf6b.xlsm"
wb = openpyxl.load_workbook(tips)
and this is the traceback:
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-16-980c37a8c9f7> in <module>()
----> 1 wb = openpyxl.load_workbook(tips)
C:\ProgramData\Anaconda3\lib\site-packages\openpyxl\reader\excel.py in load_workbook(filename, read_only, keep_vba, data_only, guess_types, keep_links)
291 ws._rels = [] # reset
292
--> 293 parser.assign_names()
294
295 #wb._differential_styles.styles = [] # tables may depened upon dxf
C:\ProgramData\Anaconda3\lib\site-packages\openpyxl\packaging\workbook.py in assign_names(self)
104 reserved = defn.is_reserved
105 if reserved in ("Print_Titles", "Print_Area"):
--> 106 sheet = self.wb._sheets[defn.localSheetId]
107 if reserved == "Print_Titles":
108 rows, cols = _unpack_print_titles(defn)
IndexError: list index out of range
if anyone has any clue on how to fix it that would be much appreciated. Thanks

Converting a generator into a list, but getting Error: '_io.TextIOWrapper' object has no attribute 'decode' (python 3.6.4)

I am working with a text in utf-8.
I want to tokenize it and then convert it into a list.
However I get the following error.
import nltk, jieba, re, os
with open('file.txt') as f:
tokenized_text = jieba.cut(f,cut_all=True)
type(tokenized_text)
generator
word_list = list(tokenized_text)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-5-16b25477c71d> in <module>()
----> 1 list(new)
~/anaconda3/lib/python3.6/site-packages/jieba/__init__.py in cut(self, sentence, cut_all, HMM)
280 - HMM: Whether to use the Hidden Markov Model.
281 '''
--> 282 sentence = strdecode(sentence)
283
284 if cut_all:
~/anaconda3/lib/python3.6/site-packages/jieba/_compat.py in strdecode(sentence)
35 if not isinstance(sentence, text_type):
36 try:
---> 37 sentence = sentence.decode('utf-8')
38 except UnicodeDecodeError:
39 sentence = sentence.decode('gbk', 'ignore')
AttributeError: '_io.TextIOWrapper' object has no attribute 'decode'
I understand the problem lies somewhere in the jieba package.
I also tried to change the code into
with open('file.txt') as f:
new = jieba.cut(f,cut_all=False)
but got the same result.
jieba.cut takes a string, not a file. This is explained in the readme.

ModuleNotFoundError: No module named 'autoreload'

I run the following code from convolutional neural network tutorials on jupyter notebook with python 3 kernel, and got the ModuleNotFoundError: No module named 'autoreload';
import numpy as np
import h5py
import matplotlib.pyplot as plt
%matplotlib inline
plt.rcParams['figure.figsize'] = (5.0, 4.0) # set default size of plots
plt.rcParams['image.interpolation'] = 'nearest'
plt.rcParams['image.cmap'] = 'gray'
%load_ext autoreload
%autoreload 2
np.random.seed(1)
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-3d0ea63c7843> in <module>()
8 plt.rcParams['image.cmap'] = 'gray'
9
---> 10 get_ipython().magic('load_ext autoreload # reload modules before executing user code')
11 get_ipython().magic('autoreload 2 # Reload all modules (except those excluded by %aimport)')
12
/opt/conda/lib/python3.6/site-packages/IPython/core/interactiveshell.py in magic(self, arg_s)
2156 magic_name, _, magic_arg_s = arg_s.partition(' ')
2157 magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2158 return self.run_line_magic(magic_name, magic_arg_s)
2159
2160 #-------------------------------------------------------------------------
/opt/conda/lib/python3.6/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line)
2077 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2078 with self.builtin_trap:
-> 2079 result = fn(*args,**kwargs)
2080 return result
2081
<decorator-gen-62> in load_ext(self, module_str)
/opt/conda/lib/python3.6/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
186 # but it's overkill for just that one bit of state.
187 def magic_deco(arg):
--> 188 call = lambda f, *a, **k: f(*a, **k)
189
190 if callable(arg):
/opt/conda/lib/python3.6/site-packages/IPython/core/magics/extension.py in load_ext(self, module_str)
35 if not module_str:
36 raise UsageError('Missing module name.')
---> 37 res = self.shell.extension_manager.load_extension(module_str)
38
39 if res == 'already loaded':
/opt/conda/lib/python3.6/site-packages/IPython/core/extensions.py in load_extension(self, module_str)
81 if module_str not in sys.modules:
82 with prepended_to_syspath(self.ipython_extension_dir):
---> 83 __import__(module_str)
84 mod = sys.modules[module_str]
85 if self._call_load_ipython_extension(mod):
ModuleNotFoundError: No module named 'autoreload'
I just couldn't find any solution on this issue. How should I fix this error?
The module autoreload belongs to the library IPython, which is running in the background on Jupyter.
The same error occurred to me and it was due to a blank space, see:
.
So make sure that there are no spaces at the end of the command!
I hit this same error because I had a comment after the magic command:
bad:
%load_ext autoreload # this comment should be removed
good:
%load_ext autoreload

Resources