I am trying to learn kivy and create application in it. during the design language in .kv file, I found:
File "D:\Python divane\pythonProject1\kivy\k#1.py", line 20, in <module>
Care4Me().run()
File "D:\Python divane\pythonProject1\lib\site-packages\kivy\app.py", line 949, in run
self._run_prepare()
File "D:\Python divane\pythonProject1\lib\site-packages\kivy\app.py", line 918, in _run_prepare
self.load_kv(filename=self.kv_file)
File "D:\Python divane\pythonProject1\lib\site-packages\kivy\app.py", line 691, in load_kv
root = Builder.load_file(rfilename)
File "D:\Python divane\pythonProject1\lib\site-packages\kivy\lang\builder.py", line 306, in load_file
return self.load_string(data, **kwargs)
File "D:\Python divane\pythonProject1\lib\site-packages\kivy\lang\builder.py", line 373, in load_string
parser = Parser(content=string, filename=fn)
File "D:\Python divane\pythonProject1\lib\site-packages\kivy\lang\parser.py", line 402, in __init__
self.parse(content)
File "D:\Python divane\pythonProject1\lib\site-packages\kivy\lang\parser.py", line 511, in parse
objects, remaining_lines = self.parse_level(0, lines)
File "D:\Python divane\pythonProject1\lib\site-packages\kivy\lang\parser.py", line 614, in parse_level
_objects, _lines = self.parse_level(
File "D:\Python divane\pythonProject1\lib\site-packages\kivy\lang\parser.py", line 624, in parse_level
raise ParserException(self, ln,
kivy.lang.parser.ParserException: Parser: File "D:\Python divane\pythonProject1\kivy\care4me.kv", line 3:
...
1:<grid>
2: Label:
>> 3: text = 'OOOOoooo'
...
Invalid property name
This ParserError was throwmn by kivy.
The.kv file:
<grid>
Label:
text = 'OOOOoooo'
I am new to kivy and and trying to make an application that I have made in tkinter
You must change to
text: "OOOOoooo"
(Use :, not =).
Related
When I run my program from PyCharm, it runs without any problems. However, when building an exe using PyInstaller I am getting a very strange error, especially as this error message is referencing a line number that does not exist.
Here is the full error message:
Traceback (most recent call last):
File "ngcmain.py", line 441, in <module>
File "pdesigner.py", line 1253, in showhome
File "kivy\app.py", line 950, in run
File "kivy\base.py", line 582, in runTouchApp
File "kivy\base.py", line 347, in mainloop
File "kivy\base.py", line 391, in idle
File "kivy\base.py", line 342, in dispatch_input
File "kivy\base.py", line 308, in post_dispatch_input
File "kivy\_event.pyx", line 709, in kivy._event.EventDispatcher.dispatch
File "kivy\uix\behaviors\button.py", line 179, in on_touch_up
File "kivy\_event.pyx", line 705, in kivy._event.EventDispatcher.dispatch
File "kivy\_event.pyx", line 1248, in kivy._event.EventObservers.dispatch
File "kivy\_event.pyx", line 1132, in kivy._event.EventObservers._dispatch
File "kivy\lang\builder.py", line 57, in custom_callback
File "<string>", line 279, in <module>
File "pdesigner.py", line 201, in show_procguides
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "procguides.py", line 18, in <module>
ModuleNotFoundError: No module named 'kivymd.button'
The error refers to line 18 in procguides.py, but this line does not exist as you can see in the following code fragment:
from kivy.uix.screenmanager import Screen
from kivy.lang import Builder
from procguideskv import style
Builder.load_string(style)
class ProcguidesScreen(Screen):
def __init__(self, **kwargs):
super(ProcguidesScreen, self).__init__(**kwargs)
def on_enter(self):
pass
Also there is no reference to kivymd.button in the procguideskv.py file:
style = r'''
<ProcguidesScreen>
name: 'ProcguidesScreen'
id: procguidesscreen
procguidesscreen:procguidesscreen
BoxLayout:
canvas.before:
Color:
rgb: 1,1,1
Rectangle:
pos: self.pos
size: self.size
'''
I am using the following packages/versions:
Python 3.9.5
Kivy 2.0.0
kivymd 0.104.2
pyinstaller 4.5.1
pyinstaller-hooks-contrib 2021.2
What am I missing here? What is going wrong?
Thanks in advance for your help. Much appreciated.
Can someone explain why multiprocessing works so weird with kivy?
Minimum example:
from kivy.app import App
from kivy.uix.button import Button
from multiprocessing import Process
class myApp(App):
def f(self):
print('test')
def test(self, caller):
pr = Process(target=self.f)
pr.start()
def build(self):
btn = Button(text='Go')
btn.bind(on_press=self.test)
return btn
if __name__ == '__main__':
myApp().run()
I get the following error:
Traceback (most recent call last):
File "/Users/eab06/Desktop/WJB/PythonProjects/Boring Button/test.py", line 20, in <module>
myApp().run()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/kivy/app.py", line 950, in run
runTouchApp()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/kivy/base.py", line 582, in runTouchApp
EventLoop.mainloop()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/kivy/base.py", line 347, in mainloop
self.idle()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/kivy/base.py", line 391, in idle
self.dispatch_input()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/kivy/base.py", line 342, in dispatch_input
post_dispatch_input(*pop(0))
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/kivy/base.py", line 248, in post_dispatch_input
listener.dispatch('on_motion', etype, me)
File "_event.pyx", line 709, in kivy._event.EventDispatcher.dispatch
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/kivy/core/window/__init__.py", line 1412, in on_motion
self.dispatch('on_touch_down', me)
File "_event.pyx", line 709, in kivy._event.EventDispatcher.dispatch
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/kivy/core/window/__init__.py", line 1428, in on_touch_down
if w.dispatch('on_touch_down', touch):
File "_event.pyx", line 709, in kivy._event.EventDispatcher.dispatch
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/kivy/uix/behaviors/button.py", line 151, in on_touch_down
self.dispatch('on_press')
File "_event.pyx", line 705, in kivy._event.EventDispatcher.dispatch
File "_event.pyx", line 1248, in kivy._event.EventObservers.dispatch
File "_event.pyx", line 1172, in kivy._event.EventObservers._dispatch
File "/Users/eab06/Desktop/WJB/PythonProjects/Boring Button/test.py", line 11, in test
pr.start()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/context.py", line 283, in _Popen
return Popen(process_obj)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 32, in __init__
super().__init__(process_obj)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 47, in _launch
reduction.dump(process_obj, fp)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/multiprocessing/reduction.py", line 60, in dump
ForkingPickler(file, protocol).dump(obj)
File "stringsource", line 2, in kivy._event.EventDispatcher.__reduce_cython__
TypeError: no default __reduce__ due to non-trivial __cinit__
The thing is, I swear I got this to work an hour ago, but I changed some things and forgot to fork. Any help/explanation would be appreciated.
VSCode Version: 1.44.0
pytest verison: 4.4.1
Python extension: Python 2020.3.71659
VSCode popup: Test discovery error, please check the configuration settings for the tests.
OUTPUT log as below:
python /Users/eason/.vscode/extensions/ms-python.python-2020.3.71659/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /Users/eason/android_guess_auto -s --cache-clear ./TestCases
Test Discovery failed:
Error: Traceback (most recent call last):
File "/Users/eason/.vscode/extensions/ms-python.python-2020.3.71659/pythonFiles/testing_tools/run_adapter.py", line 22, in <module>
main(tool, cmd, subargs, toolargs)
File "/Users/eason/.vscode/extensions/ms-python.python-2020.3.71659/pythonFiles/testing_tools/adapter/__main__.py", line 100, in main
parents, result = run(toolargs, **subargs)
File "/Users/eason/.vscode/extensions/ms-python.python-2020.3.71659/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 30, in discover
ec = _pytest_main(pytestargs, [_plugin])
File "/Users/eason/test_3env/lib/python3.6/site-packages/_pytest/config/__init__.py", line 60, in main
config = _prepareconfig(args, plugins)
File "/Users/eason/test_3env/lib/python3.6/site-packages/_pytest/config/__init__.py", line 201, in _prepareconfig
pluginmanager=pluginmanager, args=args
File "/Users/eason/test_3env/lib/python3.6/site-packages/pluggy/hooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "/Users/eason/test_3env/lib/python3.6/site-packages/pluggy/manager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/Users/eason/test_3env/lib/python3.6/site-packages/pluggy/manager.py", line 87, in <lambda>
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
File "/Users/eason/test_3env/lib/python3.6/site-packages/pluggy/callers.py", line 203, in _multicall
gen.send(outcome)
File "/Users/eason/test_3env/lib/python3.6/site-packages/_pytest/helpconfig.py", line 93, in pytest_cmdline_parse
config = outcome.get_result()
File "/Users/eason/test_3env/lib/python3.6/site-packages/pluggy/callers.py", line 80, in get_result
raise ex[1].with_traceback(ex[2])
File "/Users/eason/test_3env/lib/python3.6/site-packages/pluggy/callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "/Users/eason/test_3env/lib/python3.6/site-packages/_pytest/config/__init__.py", line 679, in pytest_cmdline_parse
self.parse(args)
File "/Users/eason/test_3env/lib/python3.6/site-packages/_pytest/config/__init__.py", line 896, in parse
self._preparse(args, addopts=addopts)
File "/Users/eason/test_3env/lib/python3.6/site-packages/_pytest/config/__init__.py", line 829, in _preparse
self._initini(args)
File "/Users/eason/test_3env/lib/python3.6/site-packages/_pytest/config/__init__.py", line 752, in _initini
config=self,
File "/Users/eason/test_3env/lib/python3.6/site-packages/_pytest/config/findpaths.py", line 122, in determine_setup
rootdir, inifile, inicfg = getcfg([ancestor], config=config)
File "/Users/eason/test_3env/lib/python3.6/site-packages/_pytest/config/findpaths.py", line 35, in getcfg
iniconfig = py.iniconfig.IniConfig(p)
File "/Users/eason/test_3env/lib/python3.6/site-packages/py/_vendored_packages/iniconfig.py", line 54, in __init__
tokens = self._parse(iter(f))
File "/Users/eason/test_3env/lib/python3.6/site-packages/py/_vendored_packages/iniconfig.py", line 82, in _parse
for lineno, line in enumerate(line_iter):
File "/Users/eason/test_3env/bin/../lib/python3.6/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 80: ordinal not in range(128)
I just installed Anaconda, but when I start Spyder it displays "An error occured while starting the kernel".
I tried updating everything, and unistalling/reinstalling Anaconda (inspired by what I have seen on other posts), but it doesn't work.
(It doesn't work either if I use the Jupiter or other programs).
Here is the full error message:
Traceback (most recent call last):
File "C:\Users\Quentin\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\Quentin\Anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Quentin\Anaconda3\lib\site‑packages\spyder_kernels\console\__main__.py", line 11, in
start.main()
File "C:\Users\Quentin\Anaconda3\lib\site‑packages\spyder_kernels\console\start.py", line 306, in main
kernel.initialize()
File "", line 2, in initialize
File "C:\Users\Quentin\Anaconda3\lib\site‑packages\traitlets\config\application.py", line 87, in catch_config_error
return method(app, *args, **kwargs)
File "C:\Users\Quentin\Anaconda3\lib\site‑packages\ipykernel\kernelapp.py", line 562, in initialize
self.init_kernel()
File "C:\Users\Quentin\Anaconda3\lib\site‑packages\ipykernel\kernelapp.py", line 447, in init_kernel
user_ns=self.user_ns,
File "C:\Users\Quentin\Anaconda3\lib\site‑packages\traitlets\config\configurable.py", line 412, in instance
inst = cls(*args, **kwargs)
File "C:\Users\Quentin\Anaconda3\lib\site‑packages\spyder_kernels\console\kernel.py", line 37, in __init__
super(SpyderKernel, self).__init__(*args, **kwargs)
File "C:\Users\Quentin\Anaconda3\lib\site‑packages\ipykernel\ipkernel.py", line 68, in __init__
kernel = self,
File "C:\Users\Quentin\Anaconda3\lib\site‑packages\traitlets\config\configurable.py", line 412, in instance
inst = cls(*args, **kwargs)
File "C:\Users\Quentin\Anaconda3\lib\site‑packages\IPython\core\interactiveshell.py", line 687, in __init__
self.init_magics()
File "C:\Users\Quentin\Anaconda3\lib\site‑packages\ipykernel\zmqshell.py", line 593, in init_magics
super(ZMQInteractiveShell, self).init_magics()
File "C:\Users\Quentin\Anaconda3\lib\site‑packages\IPython\core\interactiveshell.py", line 2250, in init_magics
m.PylabMagics, m.ScriptMagics,
File "C:\Users\Quentin\Anaconda3\lib\site‑packages\IPython\core\magic.py", line 405, in register
m = m(shell=self.shell)
File "C:\Users\Quentin\Anaconda3\lib\site‑packages\IPython\core\magics\osm.py", line 52, in __init__
self.execre = re.compile(r'(.*)\.(%s)$' % winext,re.IGNORECASE)
File "C:\Users\Quentin\Anaconda3\lib\re.py", line 234, in compile
return _compile(pattern, flags)
File "C:\Users\Quentin\Anaconda3\lib\re.py", line 286, in _compile
p = sre_compile.compile(pattern, flags)
File "C:\Users\Quentin\Anaconda3\lib\sre_compile.py", line 764, in compile
p = sre_parse.parse(p, flags)
File "C:\Users\Quentin\Anaconda3\lib\sre_parse.py", line 924, in parse
p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
File "C:\Users\Quentin\Anaconda3\lib\sre_parse.py", line 420, in _parse_sub
not nested and not items))
File "C:\Users\Quentin\Anaconda3\lib\sre_parse.py", line 810, in _parse
p = _parse_sub(source, state, sub_verbose, nested + 1)
File "C:\Users\Quentin\Anaconda3\lib\sre_parse.py", line 420, in _parse_sub
not nested and not items))
File "C:\Users\Quentin\Anaconda3\lib\sre_parse.py", line 501, in _parse
code = _escape(source, this, state)
File "C:\Users\Quentin\Anaconda3\lib\sre_parse.py", line 402, in _escape
raise source.error("bad escape %s" % escape, len(escape))
re.error: bad escape \M at position 52
I would be very grateful if someone would help me.
So I met someone who was good at this and he solved my problem.
He somehow figured out that there was a problem with my environnement variables.
In the environnement variables, in the system variable PATHEXT, are stored some extensions (.COM, .EXE, .CMD,...) that can be recognized by the system. I had an alien in mine, which was not an extension (in that case, it was "C:/HOME/MinGW").
I deleted it and it worked.
This can be set via Window's configuration pannel -> modify system environnement variable. Then press on "environnement variables". On the "system variable" list, select "PATHEXT" and press "modify...".
(NB: My Windows is in French so the names are translated by myself and may not perfectly match to other languages'Windows)
I have a file global_vars.py that contains file paths saved as variables:
from pandas import Timestamp
final_vol_path = 'datasets/final_vols.csv'
final_price_path = 'datasets/final_prices.csv'
final_start_date = Timestamp('2017-01-01')
with other variables written in a similar fashion. However, the functions that I'm using to read in the data throw a FileNotFoundError when attempting to do the following in file1.py:
import scripts.global_vars as gv
read_data(gv.final_vol_path, gv.final_price_path) # throws FileNotFoundError
read_data('datasets/final_vols.csv', 'datasets/final_prices.csv') # this passes
Additionally, I've checked the file paths, and have gotten the following:
gv.final_vol_path == 'datasets/final_vols.csv' # returns True
gv.final_price_path == 'datasets/final_prices.csv' # returns True
Moreover, the pandas Timestamp object is processed without any problems.
Is there any explanation for why the FileNotFoundError is being thrown when attempting to access the file path as a variable from global_vars.py, but is not thrown when the actual string is passed in?
EDIT: The overall directory structure is as follows:
working_dir
L file1.py
L scripts
L global_vars.py
L datasets
L final_vols.csv
L final_prices.csv
EDIT 2: I added in a try-catch block to ensure the rest of the function doesn't break, not sure if that has affected the traceback, but here's what I get:
Traceback (most recent call last):
File "c:\users\ananth\anaconda3\envs\analytics-cpu\lib\runpy.py", line
184, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\ananth\anaconda3\envs\analytics-cpu\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Ananth\Anaconda3\envs\analytics-cpu\Scripts\nose2.exe\__main__.py", line 9, in <module>
File "c:\users\ananth\anaconda3\envs\analytics-cpu\lib\site-packages\nose2\main.py", line 306, in discover
return main(*args, **kwargs)
File "c:\users\ananth\anaconda3\envs\analytics-cpu\lib\site-packages\nose2\main.py", line 100, in __init__
super(PluggableTestProgram, self).__init__(**kw)
File "c:\users\ananth\anaconda3\envs\analytics-cpu\lib\unittest\main.py", line 93, in __init__
self.parseArgs(argv)
File "c:\users\ananth\anaconda3\envs\analytics-cpu\lib\site-packages\nose2\main.py", line 133, in parseArgs
self.createTests()
File "c:\users\ananth\anaconda3\envs\analytics-cpu\lib\site-packages\nose2\main.py", line 258, in createTests
self.testNames, self.module)
File "c:\users\ananth\anaconda3\envs\analytics-cpu\lib\site-packages\nose2\loader.py", line 69, in loadTestsFromNames
for name in event.names]
File "c:\users\ananth\anaconda3\envs\analytics-cpu\lib\site-packages\nose2\loader.py", line 69, in <listcomp>
for name in event.names]
File "c:\users\ananth\anaconda3\envs\analytics-cpu\lib\site-packages\nose2\loader.py", line 84, in loadTestsFromName
result = self.session.hooks.loadTestsFromName(event)
File "c:\users\ananth\anaconda3\envs\analytics-cpu\lib\site-packages\nose2\events.py", line 224, in __call__
result = getattr(plugin, self.method)(event)
File "c:\users\ananth\anaconda3\envs\analytics-cpu\lib\site-packages\nose2\plugins\loader\testcases.py", line 56, in loadTestsFromName
result = util.test_from_name(name, module)
File "c:\users\ananth\anaconda3\envs\analytics-cpu\lib\site-packages\nose2\util.py", line 106, in test_from_name
parent, obj = object_from_name(name, module)
File "c:\users\ananth\anaconda3\envs\analytics-cpu\lib\site-packages\nose2\util.py", line 117, in object_from_name
module = __import__('.'.join(parts_copy))
File "C:\Users\Ananth\Desktop\Modules\PortfolioVARModule\tests\test_simulation.py", line 24, in <module>
gv.test_start_date)
File "C:\Users\Ananth\Desktop\Modules\PortfolioVARModule\scripts\prep_data.py", line 119, in read_data
priceDF = pd.read_csv(pricepath).dropna()
File "c:\users\ananth\anaconda3\envs\analytics-cpu\lib\site-packages\pandas\io\parsers.py", line 646, in parser_f
return _read(filepath_or_buffer, kwds)
File "c:\users\ananth\anaconda3\envs\analytics-cpu\lib\site-packages\pandas\io\parsers.py", line 389, in _read
parser = TextFileReader(filepath_or_buffer, **kwds)
File "c:\users\ananth\anaconda3\envs\analytics-cpu\lib\site-packages\pandas\io\parsers.py", line 730, in __init__
self._make_engine(self.engine)
File "c:\users\ananth\anaconda3\envs\analytics-cpu\lib\site-packages\pandas\io\parsers.py", line 923, in _make_engine
self._engine = CParserWrapper(self.f, **self.options)
File "c:\users\ananth\anaconda3\envs\analytics-cpu\lib\site-packages\pandas\io\parsers.py", line 1390, in __init__
self._reader = _parser.TextReader(src, **kwds)
File "pandas\parser.pyx", line 373, in pandas.parser.TextReader.__cinit__ (pandas\parser.c:4184)
File "pandas\parser.pyx", line 667, in pandas.parser.TextReader._setup_parser_source (pandas\parser.c:8449)
FileNotFoundError: File b'datasets/corn_price.csv' does not exist
Problem is the addition of the letter b in front of your file's path.
You get the b because you encoded to utf-8.
Try:
read_data(str(gv.final_vol_path,'utf-8'), str(gv.final_price_path, 'utf-8'))