Python 如何<&书信电报;要求(“核心/util/projections”)>&燃气轮机;使用Bokeh服务器?

Python 如何<&书信电报;要求(“核心/util/projections”)>&燃气轮机;使用Bokeh服务器?,python,python-3.x,plot,bokeh,mercator,Python,Python 3.x,Plot,Bokeh,Mercator,如果我在jupyter实验室运行这个示例,效果会很好 from bokeh.io import output_notebook, show, push_notebook from bokeh.models import HoverTool, CustomJSHover from bokeh.tile_providers import CARTODBPOSITRON from bokeh.plotting import figure output_notebook() # range bound

如果我在jupyter实验室运行这个示例,效果会很好

from bokeh.io import output_notebook, show, push_notebook
from bokeh.models import HoverTool, CustomJSHover
from bokeh.tile_providers import CARTODBPOSITRON
from bokeh.plotting import figure
output_notebook()

# range bounds supplied in web mercator coordinates
p = figure(x_range=(-2000000, 6000000), y_range=(-1000000, 7000000),
        x_axis_type="mercator", y_axis_type="mercator")
p.add_tile(CARTODBPOSITRON)

p.circle(x=[0, 2000000, 4000000], y=[4000000, 2000000, 0], size=30)

code = """
    var projections = require("core/util/projections");
    var x = special_vars.x
    var y = special_vars.y
    var coords = projections.wgs84_mercator.inverse([x, y])
    return coords[%d].toFixed(2)
"""

p.add_tools(HoverTool(
    tooltips=[
        ( 'lon',   '@x{custom}' ),
        ( 'lat',   '@y{custom}' ),
    ],

    formatters={
        'x' : CustomJSHover(code=code % 0),
        'y' : CustomJSHover(code=code % 1),
    }
))

show(p)

但是如果我使用bokeh服务运行这个示例,我会得到错误
未捕获错误:找不到模块'core/util/projections'

from bokeh.io import curdoc
from bokeh.models import HoverTool, CustomJSHover
from bokeh.plotting import figure
from bokeh.tile_providers import CARTODBPOSITRON

# range bounds supplied in web mercator coordinates
p = figure(x_range=(-2000000, 6000000), y_range=(-1000000, 7000000),
        x_axis_type="mercator", y_axis_type="mercator")
p.add_tile(CARTODBPOSITRON)

p.circle(x=[0, 2000000, 4000000], y=[4000000, 2000000, 0], size=30)

code = """
    var projections = require("core/util/projections");
    var x = special_vars.x
    var y = special_vars.y
    var coords = projections.wgs84_mercator.inverse([x, y])
    return coords[%d].toFixed(2)
"""

p.add_tools(HoverTool(
    tooltips=[
        ( 'lon',   '@x{custom}' ),
        ( 'lat',   '@y{custom}' ),
    ],

    formatters={
        'x' : CustomJSHover(code=code % 0),
        'y' : CustomJSHover(code=code % 1),
    }
))

curdoc().add_root(p)
我错过什么了吗?使用
bokeh-serve
运行脚本时,是否需要调整
require
调用?我没有看到任何关于博克发球的例子

我的版本

Python version      :  3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)]
IPython version     :  6.5.0
Tornado version     :  5.1
Bokeh version       :  1.0.0dev8
node.js version     :  v8.11.3
10月9日更新 实际上,我已经编译并安装了Bokeh。我得到一个404错误,因为js文件的url是url与本地路径的连接

http://localhost:5006/static/js/C:/path_to_bokeh_folder/bokeh/bokehjs/node_modules/tslib/tslib.js
恐怕我在bokeh安装期间做错了什么。我跟着

我正在使用Windows10

10月10日更新 谢谢@Torus,我已经设置了
BOKEH_RESOURCES=server dev
环境变量,但是模块也找不到

关于传统信息:我安装了bokeh,带有:

python setup.py install --build-js
我已经建立了这个:

但我仍然收到相同的错误,无法找到模块:

Cannot find module 'core/util/projections'
结论 我认为手动构建bokeh时有问题,因为如果我以通常的方式安装它:
pip install bokeh
,当我执行
require(“core/util/projections”)时,
工作正常


是否有其他方法将坐标转换为“墨卡托投影”?。我是否应该创建另一个CDS列并在python中进行转换?

您使用的是BOKEH_RESOURCES=absolute dev或BOKEH_dev=true。它不适用于bokeh服务器


BOKEH_RESOURCES=server dev BOKEH serve your_script.py
让Bokeh以正确的方式获取资源

Cannot find module 'core/util/projections'