Hi @Chen_Jack please edit your post to use code formatting so that the code is intelligible (either with the </> icon on the editing toolbar, or triple backtick ``` fences around the code blocks)
Additionally, the issue is almost certainly something specific to your code or setup. In order to investigate we would need a complete Minimal Reproducible Example.
put the button and plot in a layout and add to the document
curdoc().add_root(column(button, p))
‘’’
It is always the first line has syntax err. I wonder if any setting missing causes ast.py handler error.
Bokeh version: 2.4.2
Python version: 3.7.9
Sorry that the handler shall be code_runner.py, not ast.py.
‘’’
Traceback (most recent call last):
File “C:\users\itri2021\appdata\local\programs\python\python37\lib\site-packages\bokeh\application\handlers\code_runner.py”, line 106, in init
nodes = ast.parse(source, os.fspath(path))
File “C:\users\itri2021\appdata\local\programs\python\python37\lib\ast.py”, line 35, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File “D:\project\BokehTest\myapp.py”, line 1
# myapp.py
^
SyntaxError: invalid character in identifier
‘’’
Hi @Chen_Jack please note that for code formatting, it is backtick characters ``` not single quotes.
I cannot reproduce any problem with the code on that page, it runs as expected with Bokeh 2.4.2. You will need to provide more details about your system and exactly what you are doing. But as a first step I would actually suggest that you clone the main repo and try to run some of the examples from the examples directory there directly:
Perhaps there is some editor or copy past issue with hidden characters that is causing an issue for you on your local system. All the examples in the repo are test to work continuously in our automated CI system.
Hi @Bryan , The file created by notepad is working and the file created by Visual Studo Code wasn’t. My Visual Studio Code version is 1.67.0. Still cannot find hidden characters but that should be the problem. Many thanks!