I installed Jupyter in Ubuntu, and I use Anaconda. When I try to open a new empty ipython notebook, I get the error 'NameError: global name 'datetime' is not defined'. I transcribe below the complete error message:
[IPKernelApp] ERROR | Invalid Message
Traceback (most recent call last):
File "/home/luiz/anaconda/lib/python2.7/site-packages/ipykernel/kernelbase.py", line 175, in dispatch_shell
msg = self.session.deserialize(msg, content=True, copy=False)
File "/home/luiz/anaconda/lib/python2.7/site-packages/jupyter_client/session.py", line 870, in deserialize
return adapt(message)
File "/home/luiz/anaconda/lib/python2.7/site-packages/jupyter_client/adapter.py", line 386, in adapt
header['date'] = datetime.now().isoformat()
NameError: global name 'datetime' is not defined
[IPKernelApp] ERROR | Invalid Message
Traceback (most recent call last):
File "/home/luiz/anaconda/lib/python2.7/site-packages/ipykernel/kernelbase.py", line 175, in dispatch_shell
msg = self.session.deserialize(msg, content=True, copy=False)
File "/home/luiz/anaconda/lib/python2.7/site-packages/jupyter_client/session.py", line 870, in deserialize
return adapt(message)
File "/home/luiz/anaconda/lib/python2.7/site-packages/jupyter_client/adapter.py", line 386, in adapt
header['date'] = datetime.now().isoformat()
NameError: global name 'datetime' is not defined
What am I missing?
Oops, I needed to update some iPython dependencies. Problem solved!
Thanks!
Related
After successfully adding a pot file to my new i18n folder in my local machine, as well as setting "translate=True" in a couple of fields in my carddecks module, and verifying that in localhost I could acess my model data, I decided to update my server.
But when I try to access my model data I get the following error:
LINE 1: ..."write_date", COALESCE("carddecks_card"."cardText"->>'pt_PT'...
^
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
Anyone might know what may be causing this?
source code for the module can be found at https://github.com/diogocsc/carddecks
Full error:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/odoo/http.py", line 1579, in _serve_db
return service_model.retrying(self._serve_ir_http, self.env)
File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 134, in retrying
result = func()
File "/usr/lib/python3/dist-packages/odoo/http.py", line 1608, in _serve_ir_http
response = self.dispatcher.dispatch(rule.endpoint, args)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 1805, in dispatch
result = self.request.registry['ir.http']._dispatch(endpoint)
File "/usr/lib/python3/dist-packages/odoo/addons/website/models/ir_http.py", line 235, in _dispatch
response = super()._dispatch(endpoint)
File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_http.py", line 144, in _dispatch
result = endpoint(**request.params)
File "/usr/lib/python3/dist-packages/odoo/http.py", line 698, in route_wrapper
result = endpoint(self, *args, **params_ok)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/dataset.py", line 42, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/dataset.py", line 33, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 457, in call_kw
result = _call_kw_model(method, model, args, kwargs)
File "/usr/lib/python3/dist-packages/odoo/api.py", line 430, in _call_kw_model
result = method(recs, *args, **kwargs)
File "/usr/lib/python3/dist-packages/odoo/addons/web/models/models.py", line 62, in web_search_read
records = self.search_read(domain, fields, offset=offset, limit=limit, order=order)
File "/usr/lib/python3/dist-packages/odoo/models.py", line 4968, in search_read
result = records.read(fields, **read_kwargs)
File "/usr/lib/python3/dist-packages/odoo/models.py", line 2992, in read
self._read(stored_fields)
File "/usr/lib/python3/dist-packages/odoo/models.py", line 3235, in _read
cr.execute(query_str, params + [sub_ids])
File "/usr/lib/python3/dist-packages/odoo/sql_db.py", line 315, in execute
res = self._obj.execute(query, params)
psycopg2.errors.UndefinedFunction: operator does not exist: character varying ->> unknown
LINE 1: ..."write_date", COALESCE("carddecks_card"."cardText"->>'pt_PT'...
^
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
The above server error caused the following client error:
OwlError: The following error occurred in onWillStart: "Odoo Server Error"
at wrapError (https://www.relationalgames.com/web/assets/504-41b52e3/web.assets_common.min.js:1445:77)
at onWillStart (https://www.relationalgames.com/web/assets/504-41b52e3/web.assets_common.min.js:1451:117)
at useModel (https://www.relationalgames.com/web/assets/505-11285c6/web.assets_backend.min.js:4709:1)
at ListController.setup (https://www.relationalgames.com/web/assets/505-11285c6/web.assets_backend.min.js:4430:645)
at new ComponentNode (https://www.relationalgames.com/web/assets/504-41b52e3/web.assets_common.min.js:1407:136)
at https://www.relationalgames.com/web/assets/504-41b52e3/web.assets_common.min.js:1929:6
at View.slot1 (eval at compile (https://www.relationalgames.com/web/assets/504-41b52e3/web.assets_common.min.js:1892:370), <anonymous>:15:36)
at callSlot (https://www.relationalgames.com/web/assets/504-41b52e3/web.assets_common.min.js:1508:25)
at WithSearch.template (eval at compile (https://www.relationalgames.com/web/assets/504-41b52e3/web.assets_common.min.js:1892:370), <anonymous>:8:12)
at Fiber._render (https://www.relationalgames.com/web/assets/504-41b52e3/web.assets_common.min.js:1336:96)
Caused by: RPC_ERROR: Odoo Server Error
at makeErrorFromResponse (https://www.relationalgames.com/web/assets/505-11285c6/web.assets_backend.min.js:967:163)
at XMLHttpRequest.<anonymous> (https://www.relationalgames.com/web/assets/505-11285c6/web.assets_backend.min.js:974:13)
Found the answer for this. In my localhost I was updating my module. In my server i was just running docker-compose up. Not updating the module in the db.
The solution was going to settings -> apps search by cardecks and upgrade it.
I am trying to create a issue with Jira pack and with I am trying to oauth with token i am getting the following error:
{
"stdout": "",
"stderr": "Traceback (most recent call last):
File \"/opt/stackstorm/st2/lib/python3.8/site-packages/st2common/runners/utils.py\", line 132, in get_action_class_instance
action_instance = action_cls(**kwargs)
TypeError: __init__() got an unexpected keyword argument 'action_service'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File \"/opt/stackstorm/st2/lib/python3.8/site-packages/python_runner/python_action_wrapper.py\", line 395, in <module>
obj.run()
File \"/opt/stackstorm/st2/lib/python3.8/site-packages/python_runner/python_action_wrapper.py\", line 213, in run
action = self._get_action_instance()
File \"/opt/stackstorm/st2/lib/python3.8/site-packages/python_runner/python_action_wrapper.py\", line 290, in _get_action_instance
action_instance = get_action_class_instance(
File \"/opt/stackstorm/st2/lib/python3.8/site-packages/st2common/runners/utils.py\", line 143, in get_action_class_instance
action_instance = action_cls(**kwargs)
File \"/opt/stackstorm/packs/jira/actions/lib/base.py\", line 17, in __init__
self._client = self._get_client()
File \"/opt/stackstorm/packs/jira/actions/lib/base.py\", line 27, in _get_client
rsa_cert_file = config['rsa_cert_file']
KeyError: 'rsa_cert_file'
3:01
Tried to create an issue via StackStorm with the UI/RestApi.
Failed with oauth method and success with basic method.
Can someone suggest how can i resolve this?
Thanks,
Or Hasson
I am using "confluent-kafka==1.0.1". It works fine when I am using py3 and ubuntu18, but fails with py3 and ubuntu14. I get the following error.
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/metrics_agent/kafka_writer.py", line 147, in enqueue_for_topic
producer.produce(topic_name, msg, partition=_get_partition(producer, topic_name))
File "/usr/local/lib/python3.4/dist-packages/confluent_kafka/serializing_producer.py", line 168, in produce
raise KeySerializationError(se)
confluent_kafka.error.KeySerializationError:
KafkaError{code=_KEY_SERIALIZATION,val=-162,str="'bytes' object has no attribute 'encode'"}
Exception KafkaError{code=_KEY_SERIALIZATION,val=-162,str="'bytes' object has no attribute
'encode'"}
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/confluent_kafka/serializing_producer.py", line 166, in produce
key = self._key_serializer(key, ctx)
File "/usr/local/lib/python3.4/dist-packages/confluent_kafka/serialization/__init__.py", line 369, in __call__
return obj.encode(self.codec)
AttributeError: 'bytes' object has no attribute 'encode'
In an older version of Dash, I used to need to be able to say,
supress_callback_exceptions = True
Since I upgraded to the new version of Dash, now I get an error on that line:
Traceback (most recent call last):
File "dash-yahoo_options.py", line 2109, in <module>
app.config.supress_callback_exceptions = True
File "/home/idf/anaconda3/envs/dash_apps_36/lib/python3.7/site-packages/dash/_utils.py", line 81, in __setattr__
self[key] = value
File "/home/idf/anaconda3/envs/dash_apps_36/lib/python3.7/site-packages/dash/_utils.py", line 106, in __setitem__
raise AttributeError(final_msg, key)
AttributeError: ('Invalid config key. Some settings are only available via the Dash constructor', 'supress_callback_exceptions')
(dash_apps_36) idf#ubvm:~/Downloads$ vi dash-yahoo_options.py
(dash_apps_36) idf#ubvm:~/Downloads$ python dash-yahoo_options.py
Traceback (most recent call last):
File "dash-yahoo_options.py", line 2109, in <module>
app.config.supress_callback_exceptions = True
File "/home/idf/anaconda3/envs/dash_apps_36/lib/python3.7/site-packages/dash/_utils.py", line 81, in __setattr__
self[key] = value
File "/home/idf/anaconda3/envs/dash_apps_36/lib/python3.7/site-packages/dash/_utils.py", line 106, in __setitem__
raise AttributeError(final_msg, key)
AttributeError: ('Invalid config key. Some settings are only available via the Dash constructor', 'supress_callback_exceptions')
In case you missed it in the Dash change log, this misspelled fallback was removed in 1.0.0.
The configuration attribute should still supported (as at 1.6.0), you just need to use the right name.
app.config.suppress_callback_exceptions = True
i am trying to run a python program which takes input from the users like,directory name,file name and its content and then i try to create the directory in the current path with the file and then write the data into it but i get an error that "os has no attribute mkdir".
//Code
import os
print(os.getcwd())
class createfile:
__name=''
__file_name=''
__input_text=''
def read_and_create(self):
name = input("Enter the directory name, you want to create: ")
os.mkdir(self.__name)
#sdos.mkdir(self.__name)
self.__file_name=input("Enter the file name, you want to create: ")
f=open(self.___file_name,'w')
self.__input_text=input("Enter the text : ")
f.write(self.__input_text)
f.close()
def read_file_content(self):
x=open(self.__file_name,'r')
print(x.read())
o=createfile()
o.read_and_create()
o.read_file_content()
this is the error i got using Pycharm.
> "C:\Users\Aryan
> Kumar\AppData\Local\Programs\Python\Python37-32\python.exe"
> "C:/Users/Aryan Kumar/Desktop/0/os.py"
> Fatal Python error: initsite: Failed to import the site module
> Traceback (most recent call last):
> File "C:\Users\Aryan Kumar\AppData\Local\Programs\Python\Python37-32\lib\site.py", line 73,
> in <module>
> import os
> File "C:\Users\Aryan Kumar\Desktop\0\os.py", line 2, in <module>
> print(os.getcwd())
> AttributeError: module 'os' has no attribute 'getcwd'
>
> Process finished with exit code 1
this is the error i got using Spyder ide in anaconda environment
runfile('C:/Users/Aryan Kumar/Desktop/0/untitled0.py', wdir='C:/Users/Aryan Kumar/Desktop/0')
C:\Users\Aryan Kumar\Desktop\0
Enter the directory name, you want to create: aac
Traceback (most recent call last):
File "<ipython-input-4-fb1c179833e1>", line 1, in <module>
runfile('C:/Users/Aryan Kumar/Desktop/0/untitled0.py', wdir='C:/Users/Aryan Kumar/Desktop/0')
File "C:\Users\Aryan Kumar\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 709, in runfile
execfile(filename, namespace)
File "C:\Users\Aryan Kumar\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/Aryan Kumar/Desktop/0/untitled0.py", line 32, in <module>
o.read_and_create()
File "C:/Users/Aryan Kumar/Desktop/0/untitled0.py", line 18, in read_and_create
os.mkdir(self.__name)
FileNotFoundError: [WinError 3] The system cannot find the path specified: ''
This is an old question but someone might have the same problem. I also received the following error: AttributeError: module 'os' has no attribute 'getcwd'. This is because the file name is os.py. Problem solved after changing the file name.
Also found that a similar answer also provided in a different question:
https://stackoverflow.com/a/43565408/298160
Use os.curdir() in Python3 instead of os.cwd()