Similar to this question about this error message I get a
Uncaught (in promise) Error: Error rendering Bokeh model: could not find #53e7b147-e581-431b-90e1-1fe7ade39263 HTML tag
at u (bokeh.min.js?v=3c61e952b808bb7e346ce828a565a5f23aaf7708d034fa9d0906403813355d45bb4e8d8b0b23a93f032c76831d4f0221846f28699c7f5147caa62e0d31668314:585:113)
at n._resolve_root_elements (bokeh.min.js?v=3c61e952b808bb7e346ce828a565a5f23aaf7708d034fa9d0906403813355d45bb4e8d8b0b23a93f032c76831d4f0221846f28699c7f5147caa62e0d31668314:585:621)
at w (bokeh.min.js?v=3c61e952b808bb7e346ce828a565a5f23aaf7708d034fa9d0906403813355d45bb4e8d8b0b23a93f032c76831d4f0221846f28699c7f5147caa62e0d31668314:163:515)
at t.embed_items (bokeh.min.js?v=3c61e952b808bb7e346ce828a565a5f23aaf7708d034fa9d0906403813355d45bb4e8d8b0b23a93f032c76831d4f0221846f28699c7f5147caa62e0d31668314:163:1455)
when running this app
import panel as pn
import glob
file_list = glob.glob( r'/usr/src/app/apps/*.nc' )
def get_comps():
select_file = pnw.Select(name="File", options=file_list).servable(target="sidebar")
#pn.depends(select_file.param.value)
def selected_file(select_file):
return pn.pane.Str(select_file, height=100, sizing_mode='stretch_width')
return [ select_file , selected_file ]
bootstrap = pn.template.BootstrapTemplate(title='Glob Demo')
sfe = get_comps()
bootstrap.sidebar.append(sfe[0])
bootstrap.main.append(sfe[1])
bootstrap.servable()
even though the FileSelector widget sees the files and displays as expected in another example app that is ran with the same panel serve command inside a Docker container that the Glob Demo App is ran with
docker run -p 8066:8000 -v /PATH_TO_APPS/apps:/usr/src/app/apps yp2
I would love to mount a volume when running my Docker Container that I can select a file from and load with Xarray and plot with HvPlot but I am stuck at even selecting a file. I already have the app I want to serve thanks to #Marc and this question.
Panel Version : 0.13.1
OS : Ubuntu
Docker Version : 20.10.17, build 100c701
My project folder as below:
C:\HHS\Actions<mysomeclass>.py
C:\HHS\Configuration<mysomesetting>.txt
C:\HHS\Data<mysomedata>.txt
C:\HHS\Form<mysomeclass>.py
C:\HHS\Testcases<mysometestcaseclass>.py
C:\HHS\Labels\OCR\Tmp<somefile>.png
C:\HHS\main.py
C:\HHS<somebatfile>.bat
After build exe file by command: C:\HHS>pyinstaller --paths=C:\HHS\Actions;C:\HHS\Form;C:\HHS\Testcase main.py
I copy all folder Actions , Configuration, Data, Form , Testcase, all file .bat to C:\HHS\dist\main
After that I run file main.exe in dist\main. It overcome the previous issue (How to release an application write by Python (which has structure folder) to user) but I met the other issue as below:
C:\HHS\dist\main>main.exe
Which testcase do you want to test
1. Image Capture
2. Reset Base
3. OCRTestcase
4. USBOEMCommand (remember turn off Vietnamese)
Please enter that number : 1
C:\HHS\dist\main> py C:\HHS\dist\main\Testcases\ImageCapture.py
Traceback (most recent call last):
File "C:\HHS\dist\main\Testcases\ImageCapture.py", line 9, in <module>
from Actions.Config import Config
ModuleNotFoundError: No module name 'Actions'
This is my ImageCapture.py
import os
import serial
import time
import sys
import os
import logging
from Actions.Config import Config
import Actions.Common as Common
from datetime import datetime
from Actions import DBv2
from Actions.parselog2 import ParseLog
I know maybe how I import module Actions is not correct (although it can run successful by Pycharm) but not work after build exe. I don't know how to fix it. Please help me. Thanks alot.
I'm trying to implement custom XCOM backend.
Those are the steps I did:
Created "include" directory at the main Airflow dir (AIRFLOW_HOME).
Created these "custom_xcom_backend.py" file inside:
from typing import Any
from airflow.models.xcom import BaseXCom
import pandas as pd
class CustomXComBackend(BaseXCom):
#staticmethod
def serialize_value(value: Any):
if isinstance(value, pd.DataFrame):
value = value.to_json(orient='records')
return BaseXCom.serialize_value(value)
#staticmethod
def deserialize_value(result) -> Any:
result = BaseXCom.deserialize_value(result)
result = df = pd.read_json(result)
return result
Set at config file:
xcom_backend = include.custom_xcom_backend.CustomXComBackend
When I restarted webserver I got:
airflow.exceptions.AirflowConfigException: The object could not be loaded. Please check "xcom_backend" key in "core" section. Current value: "include.cust...
My guess is that it not recognizing the "include" folder
But how can I fix it?
*Note: There is no docker. It is installed on a Ubuntu machine.
Thanks!
So I solved it:
Put custom_xcom_backend.py into the plugins directory
set at config file:
xcom_backend = custom_xcom_backend.CustomXComBackend
Restart all airflow related services
*Note: Do not store DataFrames that way (bad practice).
Sources I used:
https://www.youtube.com/watch?v=iI0ymwOij88
Whenever I open a script (Python or R), I want Sublime automatically changes the current working directory to the path of that file. Is it possible?
I added the setting "working_dir": "$file_path", to Sublime preferences but it doesn't help.
Ok, I solved the problem. Here is what I did:
Install Sublime Text 3 package PackageResourceViewer
Open Command Palette, search for PackageResourceViewer: Open Resource
Browse to Python resource then open Python.sublime-build
Remove the default line "shell_cmd": "python -u \"$file\"",
Add the following 2 lines:
"cmd": ["python", "-u", "$file"],
"working_dir": "$file_path",
Alternately, you can replace the above 2 lines by:
"shell_cmd": "cd $file_path; python -u \"$file\""
Do the same thing for R or other build resources if you want Sublime Text 3 automatically change the current working directory in accordance with the active scripts' path.
You can open the python console using the Show Console command in View menu, and then type
import os
os.chdir('/my/directory')
It changes the working directory for the Sublime Text process and whatever process it spawns.
Another solution: You know the console opens with Alt+". When I use the combination Alt+1 it's directly chosing the current file path. And this way is something you have to do every single time you open sublime text.
I was having the same issue, plus if i wanted to import a module, it would always return module not found.
To fix this: I change the first line of my python.sublime-build file to what i have below
{
"shell_cmd": "cd $file_path; python -u \"$file\"",
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
{
"env": "PYTHONIOENCODING": "utf-8",
],
"variants":
}
{
"name": "Syntax Check",
"shell_cmd": "python -m py_compile \"${file}\"",
}
]
}
Being cuper curious, i wanted to know why this was happening, so after doing more investigations about my os, ran:
import os
for k, v in os.environ.items():
print(k, v)
print(os.getcwd())
which returns a dictionary of my environment variables and their values, including 2 that answered my questions in the build results PWD and OLDPWD:
PWD /Users/<myname>/code
OLDPWD /Users/<myname>/code/code_py
...
[Finished 0.0ms]
...
[shell_cmd: cd /Users/<myname>/code/code_py; python -u "/Users/<myname>/code/code_py/YT-tutorials.py"]
...
AHA!
because i previously added cd $HOME/code my ~/.bash_profile, so every time i would build (command+B) in sublime with python, my shell profile would change directories behind the scenes and move me into my ~/code directory.
Now, after changing the python.sublime-build file as mentioned above changed this build behavior has been fixed -- & i hope this helps you too!
I have installed qpython for android, the problem is that when I install a module with pip in the python console I can import it properly, but not when I try to import it to a script.
in console ... I type:
>>>import requests
>>>requests
<module 'requests' from '/data/data/com.hipipal.qpyplus/.../__init__.py>
but in a script saved in scripts' folder, when I execute:
import requests
r = requests.get("http://www.google.com")
print r.text.encode('utf-8')
I get this:
import requests
ImportError: no module named requests
Can anybody help with that?
Thank you!
Add import site.
This works on my tablet:
#-*-coding:utf8;-*-
#qpy:2
#qpy:console
import site
import requests
r = requests.get("http://www.google.com")
print r.text.encode('utf-8')