Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Jupyter #206

Answered by dorbitbrown
dorbitbrown asked this question in Q&A
Discussion options

I was successfully using Jupyter with Pyscript, but am now having a problem.

It used to be that
....In [1]: pyscript.list_global_ctx()
would give me a list of contexts, like
....Out [1] ['jupyter_3', 'jupyter_0', 'jupyter_1', 'scripts.test_script']
and then I could switch
....In [2] pyscript.set_global_ctx('scripts.test_script')
and run tests in my project's context.

Now, however, my project's context is missing, so all I get is
....Out [1] ['jupyter_3', 'jupyter_0', 'jupyter_1']
If I try to switch to the context in which I'm doing development, I get a NameError:
....Exception in <jupyter_13> line 1:
........pyscript.set_global_ctx('scripts.test_script')
.....................................^
....NameError: global context 'scripts.test_script' does not exist

I believe this problem arose after I modified config.yaml to include a Pyscript-specific yaml file:
....pyscript: !include pyscript/config.yaml
I couldn't get that to work (it just hung HA), so I deleted the pyscript/config.yaml, and reverted config.yaml back to the original state.

Any suggestions short of reinstalling Pyscript and Jupyter?

You must be logged in to vote

The root cause of the problem was a Python newbie misunderstanding; failure to distinguish between runtime errors and compile time errors.

After a runtime error in the 'scripts.test_script' context, there is still a 'scripts.test_script' global context which Jupyter can see and which will be listed by the 'pyscript.list_global_ctx()' command. However, a compile time error in the script will--of course--prevent the context from being created in the first place, which explains why it was not showing up.

Replies: 2 comments

Comment options

This was temporarily resolved by reinstalling Anaconda, but the problem recurred after about a day.

You must be logged in to vote
0 replies
Comment options

The root cause of the problem was a Python newbie misunderstanding; failure to distinguish between runtime errors and compile time errors.

After a runtime error in the 'scripts.test_script' context, there is still a 'scripts.test_script' global context which Jupyter can see and which will be listed by the 'pyscript.list_global_ctx()' command. However, a compile time error in the script will--of course--prevent the context from being created in the first place, which explains why it was not showing up.

You must be logged in to vote
0 replies
Answer selected by dorbitbrown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /