I don't get it. I try to send an e-mail with a csv-file as attachment. The first run with the script was fine, I recieved the e-mail with the csv-file as attachment. But after running it once, the script crashes with an odd Traceback message.
Heres my code so far:
import smtplib
import email.utils
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email.mime.text import MIMEText
from email import Encoders
msg = MIMEMultipart('foo')
msg['To'] = email.utils.formataddr(('foo', 'foo#foobar.de'))
msg['From'] = email.utils.formataddr(('foo', 'foo#foo'))
msg['Subject'] = 'foo'
# Attach a file
mail_file = file('foo.csv').read()
mail_file = MIMEBase('application', 'csv')
mail_file.set_payload(mail_file)
mail_file.add_header('Content-Disposition', 'attachment', filename='foo.csv')
Encoders.encode_base64(mail_file)
msg.attach(mail_file)
# Define SMTP server
server = smtplib.SMTP('localhost')
server.set_debuglevel(True) # show communication with the server
# Send the mail
try:
server.sendmail('foo#foo', ['foo#foobar.de'], msg.as_string())
finally:
server.quit()
Now I get the following traceback:
Traceback (most recent call last):
File "mail.py", line 27, in <module>
Encoders.encode_base64(mail_file)
File "/usr/lib/python2.7/email/encoders.py", line 45, in encode_base64
encdata = _bencode(orig)
File "/usr/lib/python2.7/email/encoders.py", line 31, in _bencode
hasnewline = (s[-1] == '\n')
File "/usr/lib/python2.7/email/message.py", line 294, in __getitem__
return self.get(name)
File "/usr/lib/python2.7/email/message.py", line 360, in get
name = name.lower()
AttributeError: 'int' object has no attribute 'lower'
When I uncomment line 27 (Encoding Line), I get the following:
Traceback (most recent call last):
File "mail.py", line 33, in <module>
server.sendmail('foo#foo', ['foo#foobar.de'], msg.as_string())
File "/usr/lib/python2.7/email/message.py", line 137, in as_string
g.flatten(self, unixfrom=unixfrom)
File "/usr/lib/python2.7/email/generator.py", line 83, in flatten
self._write(msg)
File "/usr/lib/python2.7/email/generator.py", line 108, in _write
self._dispatch(msg)
File "/usr/lib/python2.7/email/generator.py", line 134, in _dispatch
meth(msg)
File "/usr/lib/python2.7/email/generator.py", line 203, in _handle_multipart
g.flatten(part, unixfrom=False)
File "/usr/lib/python2.7/email/generator.py", line 83, in flatten
self._write(msg)
File "/usr/lib/python2.7/email/generator.py", line 108, in _write
self._dispatch(msg)
File "/usr/lib/python2.7/email/generator.py", line 134, in _dispatch
meth(msg)
File "/usr/lib/python2.7/email/generator.py", line 177, in _handle_text
raise TypeError('string payload expected: %s' % type(payload))
TypeError: string payload expected: <type 'instance'>
Any ideas?
Strange, when I do
mail_file.set_payload(open('foo.csv', 'rb').read())
instead of
mail_file = file('foo.csv').read()
mail_file.set_payload(mail_file)
the Code works.. Still wondering why...!?
Related
I have all the necessary dependencies installed:
pyexcel==0.7.0
pyexcel-ezodf==0.3.4
pyexcel-io==0.6.6
pyexcel-ods3==0.6.1
pyexcel-xls==0.7.0
(and some others, which I've omitted). Last week, my code was working. Now I am unable to open the very same .xls
>>> p = Path("data/jr1305221.xls")
>>> p.exists()
True
>>> pyexcel.get_book(file_name=p)
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\core.py", line 47, in get_book
book_stream = sources.get_book_stream(**keywords)
File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\internal\core.py", line 36, in get_book_stream
a_source = SOURCE.get_book_source(**keywords)
File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\internal\source_plugin.py", line 85, in get_book_source
return self.get_a_plugin(
File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\internal\source_plugin.py", line 69, in get_a_plugin
source_cls = self.load_me_now(
File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\internal\source_plugin.py", line 41, in load_me_now
if source.is_my_business(action, **keywords):
File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\plugins\__init__.py", line 56, in is_my_business
raise IOError("Unsupported file type")
OSError: Unsupported file type
>>>
or .xlsx
>>> p = Path('data/dummy.xlsx')
>>> p.exists()
True
>>> pyexcel.get_book(file_name=p)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\core.py", line 47, in get_book
book_stream = sources.get_book_stream(**keywords)
File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\internal\core.py", line 36, in get_book_stream
a_source = SOURCE.get_book_source(**keywords)
File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\internal\source_plugin.py", line 85, in get_book_source
return self.get_a_plugin(
File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\internal\source_plugin.py", line 69, in get_a_plugin
source_cls = self.load_me_now(
File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\internal\source_plugin.py", line 41, in load_me_now
if source.is_my_business(action, **keywords):
File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\plugins\__init__.py", line 56, in is_my_business
raise IOError("Unsupported file type")
OSError: Unsupported file type
>>>
Even in my docker container, it's stopped working.
As an alternative, I have also tried
with open('data/dummy.xlsx', 'r') as f:
pyexcel.get_book(file_name=f)
and get the same error.
I have read the docs again. I have rolled back my code to last week. What have I done to deserve this? Why has god forsaken me?
file_name needs to be a string, where I was passing in a pathlib.PosixPath
i.e., this returns the error:
p = Path('my_file')
pyexcel.get_book(file_name=p)
this works:
pyexcel.get_book(file_name='my_file')
You can use pyexcel.get_book(file_name=my_file.as_posix()) to get the string representation from the PosixPath.
One question of this type is previously asked but is not very helpful. I am using version Python3.8 in Windows 10 OS. I am getting an error, KeyError: 'sapi5'. dont know why this error is occurring. Please have a look at the below code given . My code is-
import pyttsx3
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voices', voices[0].id)
The Error is quite big. can anyone help me?
Traceback (most recent call last):
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\__init__.py", line 20, in init
eng = _activeEngines[driverName]
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\weakref.py", line 131, in __getitem__
o = self.data[key]()
KeyError: 'sapi5'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\drivers\sapi5.py", line 3, in <module>
from comtypes.gen import SpeechLib # comtypes
ImportError: cannot import name 'SpeechLib' from 'comtypes.gen' (C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\gen\__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\ctypes\__init__.py", line 123, in WINFUNCTYPE
return _win_functype_cache[(restype, argtypes, flags)]
KeyError: (<class 'ctypes.HRESULT'>, (<class 'ctypes.c_long'>, <class 'comtypes.automation.tagVARIANT'>, <class 'comtypes.automation.tagVARIANT'>, <class 'ctypes.c_long'>, <class 'ctypes.c_long'>), 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "g:/saurav/Assistant/VA/MyAssistant.py", line 9, in <module>
engine = pyttsx3.init('sapi5')
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\__init__.py", line 22, in init
eng = Engine(driverName, debug)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\engine.py", line 30, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\driver.py", line 50, in __init__
self._module = importlib.import_module(name)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\drivers\sapi5.py", line 6, in <module>
engine = comtypes.client.CreateObject("SAPI.SpVoice")
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\client\__init__.py", line 250, in CreateObject
return _manage(obj, clsid, interface=interface)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\client\__init__.py", line 188, in _manage
obj = GetBestInterface(obj)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\client\__init__.py", line 110, in GetBestInterface
mod = GetModule(tlib)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\client\_generate.py", line 110, in GetModule
mod = _CreateWrapper(tlib, pathname)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\client\_generate.py", line 184, in _CreateWrapper
mod = _my_import(fullname)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\client\_generate.py", line 24, in _my_import
return __import__(fullname, globals(), locals(), ['DUMMY'])
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\gen\_C866CA3A_32F7_11D2_9602_00C04F8EE628_0_5_4.py", line 140, in <module>
ISpeechRecoGrammar._methods_ = [
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\__init__.py", line 329, in __setattr__
self._make_methods(value)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\__init__.py", line 698, in _make_methods
prototype = WINFUNCTYPE(restype, *argtypes)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\ctypes\__init__.py", line 125, in WINFUNCTYPE
class WinFunctionType(_CFuncPtr):
TypeError: item 2 in _argtypes_ passes a union by value, which is unsupported.
first uninstall pyttsx3 using following command
pip uninstall pyttsx3
Then install pyttsx3 version 2.6 using following command
pip install pyttsx3==2.6
I can not read the input from the motion sensor (HC-SR501) which connects to PIN_A of the expansion pins on the voice bonnet of my aiy voice kit.
Below are the code and the error message, please shed some light.
Code:
from gpiozero import MotionSensor
from aiy.pins import (PIN_A, PIN_B, PIN_C, PIN_D)
pir = MotionSensor(PIN_A)
pir.wait_for_motion()
print("Motion detected!")
Error message:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/gpiozero/input_devices.py", line 51, in __init__
self.pin.pull = pull
File "/usr/lib/python3/dist-packages/gpiozero/pins/__init__.py", line 279, in <lambda>
lambda self, value: self._set_pull(value),
File "/opt/aiy/projects-python/src/aiy/pins.py", line 569, in _set_pull
'Only pull up is supported right now (%s)' % pull)
gpiozero.exc.PinFixedPull: Only pull up is supported right now (down)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "motion_sensor.py", line 4, in <module>
pir = MotionSensor(PIN_A)
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 95, in __call__
self = super(GPIOMeta, cls).__call__(*args, **kwargs)
File "/usr/lib/python3/dist-packages/gpiozero/input_devices.py", line 451, in __init__
pin_factory=pin_factory
File "/usr/lib/python3/dist-packages/gpiozero/input_devices.py", line 163, in __init__
pin, pull_up, pin_factory=pin_factory
File "/usr/lib/python3/dist-packages/gpiozero/mixins.py", line 164, in __init__
super(EventsMixin, self).__init__(*args, **kwargs)
File "/usr/lib/python3/dist-packages/gpiozero/input_devices.py", line 53, in __init__
self.close()
File "/usr/lib/python3/dist-packages/gpiozero/input_devices.py", line 185, in close
super(SmoothedInputDevice, self).close()
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 393, in close
self.pin_factory.release_pins(self, self._pin.number)
AttributeError: 'HatPin' object has no attribute 'number'
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 483, in _shutdown
_devices_shutdown()
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 476, in _devices_shutdown
dev.close()
File "/usr/lib/python3/dist-packages/gpiozero/input_devices.py", line 185, in close
super(SmoothedInputDevice, self).close()
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 393, in close
self.pin_factory.release_pins(self, self._pin.number)
AttributeError: 'HatPin' object has no attribute 'number'
Exception ignored in: <object repr() failed>
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 122, in __del__
self.close()
File "/usr/lib/python3/dist-packages/gpiozero/input_devices.py", line 185, in close
super(SmoothedInputDevice, self).close()
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 393, in close
self.pin_factory.release_pins(self, self._pin.number)
AttributeError: 'HatPin' object has no attribute 'number'
Did you solve it?
By looking at the API and your error message, try changing line 3 of your code
From:
pir = MotionSensor(PIN_A)
To:
pir = MotionSensor(PIN_A, pull_up=True)
I downloaded the socks.py file and placed it in the python lib folder. When I run this script:
import socks
import socket
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "localhost", 9150)
socket.socket = socks.socksocket
import requests
from bs4 import BeautifulSoup
url = 'http://www.google.ca'
r = requests.get(url)
soup = BeautifulSoup(r.content)
print (soup)
it sends an error like this:
Traceback (most recent call last):
File "/Users/Raphael/Desktop/whatsmyip.py", line 8, in <module>
r = requests.get(url)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/api.py", line 68, in get
return request('get', url, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/api.py", line 50, in request
response = session.request(method=method, url=url, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/sessions.py", line 465, in request
resp = self.send(prep, **send_kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/adapters.py", line 370, in send
timeout=timeout
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 544, in urlopen
body=body, headers=headers)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 349, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/http/client.py", line 1088, in request
self._send_request(method, url, body, headers)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/http/client.py", line 1126, in _send_request
self.endheaders(body)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/http/client.py", line 1084, in endheaders
self._send_output(message_body)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/http/client.py", line 922, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/http/client.py", line 857, in send
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 155, in connect
conn = self._new_conn()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 134, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/requests/packages/urllib3/util/connection.py", line 78, in create_connection
sock.connect(sa)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/socks.py", line 369, in connect
self.__negotiatesocks5(destpair[0],destpair[1])
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/socks.py", line 176, in __negotiatesocks5
self.sendall("\x05\x01\x00")
TypeError: 'str' does not support the buffer interface
Can someone help me? I do not know how to fix this.. No where explains what I need to do in this case. Thank you very much
i have installed openerp. i have created postgres database. While i open ¨localhost:8060¨ in browser, display the followin error:
Client Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/addons/web/http.py", line 204, in dispatch
response["result"] = method(self, **self.params)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/addons/web/controllers/main.py", line 761, in get_list
monodb = db_monodb(req)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/addons/web/controllers/main.py", line 129, in db_monodb
return db_redirect(req, True)[0]
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/addons/web/controllers/main.py", line 109, in db_redirect
dbs = db_list(req, True)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/addons/web/controllers/main.py", line 90, in db_list
dbs = proxy.list(force)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/addons/web/session.py", line 30, in proxy_method
result = self.session.send(self.service_name, method, *args)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/addons/web/session.py", line 103, in send
raise xmlrpclib.Fault(openerp.tools.ustr(e), formatted_info)
Server Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/addons/web/session.py", line 89, in send
return openerp.netsvc.dispatch_rpc(service_name, method, args)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/netsvc.py", line 292, in dispatch_rpc
result = ExportService.getService(service_name).dispatch(method, params)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/service/web_services.py", line 122, in dispatch
return fn(*params)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/service/web_services.py", line 359, in exp_list
cr = db.cursor()
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/sql_db.py", line 484, in cursor
return Cursor(self._pool, self.dbname, serialized=serialized)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/sql_db.py", line 182, in __init__
self._cnx = pool.borrow(dsn(dbname))
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/sql_db.py", line 377, in _locked
return fun(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/sql_db.py", line 440, in borrow
result = psycopg2.connect(dsn=dsn, connection_factory=PsycoConnection)
File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 179, in connect
connection_factory=connection_factory, async=async)
OperationalError: FATAL: role "bala" does not exist
otherwise i started like following ¨openerp-server start¨, error following like
Traceback (most recent call last):
File "/usr/local/bin/openerp-server", line 5, in <module>
pkg_resources.run_script('openerp==7.0-20140110-002122', 'openerp-server')
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 499, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1235, in run_script
execfile(script_filename, namespace, namespace)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/EGG-INFO/scripts/openerp-server", line 5, in <module>
openerp.cli.main()
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/cli/__init__.py", line 51, in main
__import__(m)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/modules/module.py", line 133, in load_module
mod = imp.load_module('openerp.addons.' + module_part, f, path, descr)
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/addons/l10n_si/__init__.py", line 22, in <module>
import account_wizard
File "/usr/local/lib/python2.7/dist-packages/openerp-7.0_20140110_002122-py2.7.egg/openerp/addons/l10n_si/account_wizard.py", line 22, in <module>
import tools
ImportError: No module named tools
Anyone help for error correction. i cannot clear this error even two days i spend for this.
OperationalError: FATAL: role "bala" does not exist
A user that you have told OpenERP to use does not exist in the database. You probably need to create it. I expect you missed one or more installation steps.
Look for a CREATE USER, CREATE ROLE, or createuser command in the instructions.
GRANT commands or a database ownership assignment may also be nececssary depending on what the user is supposed to be able to do.
(It might also be assumed that you'll know to create the user to connect to the DB as).