Editable installation KeyError

Hi all!

Festive wishes to all those celebrating a holiday today, and a happy summer to any in the Southern Hemisphere!

I’m trying set up bokeh in order to contribute to bokeh. I’ve followed the instructions at https://docs.bokeh.org/en/dev-3.0/docs/dev_guide/setup.html.

However, when I run bokeh info to validate that the installation is successful, I get an error.

My environment is Ubuntu, running Python 3.10 in PyCharm.

Own investigation

The same issue looks like it has been reported before in this thread, however this was on Windows and there was no resolution found.

Looking a little in the code that throws the error, in get_sri_hashes_for_version, it is noted that “This function can only be called on full release (e.g “1.2.3”) packages.”. In the toml I see the version number seems to be dynamically set, wondering if I need to configure this at all.

Looking forward if anyone can shine a light on this!

Stacktrace

When running bokeh info

:~/PycharmProjects/bokeh_dev$ bokeh info
Traceback (most recent call last):
  File "/home/____/miniconda3/envs/bokeh____/bin/bokeh", line 8, in <module>
    sys.exit(main())
  File "/home/____/PycharmProjects/bokeh_dev/src/bokeh/__main__.py", line 56, in main
    from bokeh.command.bootstrap import main as _main
  File "/home/____/PycharmProjects/bokeh_dev/src/bokeh/command/bootstrap.py", line 56, in <module>
    from . import subcommands
  File "/home/____/PycharmProjects/bokeh_dev/src/bokeh/command/subcommands/__init__.py", line 76, in <module>
    all = _collect()
  File "/home/____/PycharmProjects/bokeh_dev/src/bokeh/command/subcommands/__init__.py", line 60, in _collect
    mod = import_module("." + modname, __package__)
  File "/home/____/miniconda3/envs/bokeh____/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/____/PycharmProjects/bokeh_dev/src/bokeh/command/subcommands/static.py", line 30, in <module>
    from ..util import report_server_init_errors
  File "/home/____/PycharmProjects/bokeh_dev/src/bokeh/command/util.py", line 31, in <module>
    from bokeh.application.handlers import (
  File "/home/____/PycharmProjects/bokeh_dev/src/bokeh/application/handlers/__init__.py", line 25, in <module>
    from .code import CodeHandler
  File "/home/____/PycharmProjects/bokeh_dev/src/bokeh/application/handlers/code.py", line 47, in <module>
    from ...io.doc import curdoc, patch_curdoc
  File "/home/____/PycharmProjects/bokeh_dev/src/bokeh/io/__init__.py", line 24, in <module>
    from .doc import curdoc
  File "/home/____/PycharmProjects/bokeh_dev/src/bokeh/io/doc.py", line 30, in <module>
    from .state import curstate
  File "/home/____/PycharmProjects/bokeh_dev/src/bokeh/io/state.py", line 54, in <module>
    from ..resources import Resources, ResourcesMode
  File "/home/____/PycharmProjects/bokeh_dev/src/bokeh/resources.py", line 751, in <module>
    CDN = Resources(mode="cdn")
  File "/home/____/PycharmProjects/bokeh_dev/src/bokeh/resources.py", line 323, in __init__
    cdn = self._cdn_urls()
  File "/home/____/PycharmProjects/bokeh_dev/src/bokeh/resources.py", line 384, in _cdn_urls
    return _get_cdn_urls(self.version, self.minified)
  File "/home/____/PycharmProjects/bokeh_dev/src/bokeh/resources.py", line 710, in _get_cdn_urls
    sri_hashes = get_sri_hashes_for_version(version)
  File "/home/____/PycharmProjects/bokeh_dev/src/bokeh/resources.py", line 179, in get_sri_hashes_for_version
    return hashes[version]
KeyError: '0.0.1'

Do things work outside of PyCharm? I can’t reproduce any issue with an editable install at a zsh prompt. In general, you need to provide a lot more information, about the exact set of steps you took and the exact state of your system. It’s not really possible to speculate without being able to reproduce.

In the toml I see the version number seems to be dynamically set, wondering if I need to configure this at all.

No this is handled by setuptools-git-versioning. I suppose it’s possible you have an old (too old) version of setuptools or something. As I said, there’s not much we can attempt to do without details to reproduce.

Hi Bryan, thanks for your swift response.

I played around with the environment variables (from this page) and I discovered that on my system (Ubuntu 22.04.1 LTS) I needed to set export BOKEH_CDN_VERSION=3.1.0.dev1, or ensure it was not null. I’m not sure if this is the best solution, but I otherwise couldn’t get any of the bokeh examples (or bokeh info) to run.

To get it to play nice with my IDE environment, I needed to add this and the other environment variables from the setup guide to my user .bashrc:

export BOKEH_DEV=true
export BOKEH_RESOURCES=absolute-dev
export BOKEH_PY_LOG_LEVEL=debug
export BOKEH_PRETTY=true
export BOKEH_MINIFIED=false
export BOKEH_LOG_LEVEL=debug
export BOKEH_BROWSER=none
export BOKEH_CDN_VERSION=3.1.0.dev1

This is definitely not required, I never have this set except in very rare instances of redeploying the docs. The actual ultimate problem is that bokeh.__version__ is not being reported correctly, but I am not sure why that is the case on your system. Again, please make sure you have setuptools up to date, at least.

Edit: also please clear out anything bokeh-related in site-packages if applicable. If there is old (pre-3.0) editable install cruft there, perhaps it is interfering.

1 Like

Thanks for the pointer about the bokeh.__version__, indeed it is being set to 0.0.1 when it should be 3.0.2. I’ve tried clearing my site-packages, and creating a new conda environment. Here’s the version of setuptools in my conda environment. I’m on Python 3.10 using the environment-test-3.10.yml conda setup configuration

# Name                    Version                   Build  Channel
setuptools                65.6.3             pyhd8ed1ab_0    conda-forge

That version is sufficiently new. I’m afraid I don’t have any other immediate suggestions. Perhaps there is an issue with setuptools-git-versioning but we’d have to take that up on their tracker, I suppose. Just by way of more information, does a non-editable install work? (i.e. pip install . instead of pip install -e .)

As someone with the same issue (on windows) using pip install . did not resolve the issue.

@Maxxner your clone of the repo is missing all the tags, which are required to be present by setuptools-git-versioning. See the expanded instructions updated in this PR, that will show up in the next version of the docs:

1 Like

Thanks for pointing this out, unchecking the specific branch checkbox during forking does indeed fix the issue!

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.