Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jupyter.jupyterCommandLineArguments setting not working #9351

Closed
1 of 2 tasks
kjbrak opened this issue Mar 14, 2022 · 1 comment
Closed
1 of 2 tasks

jupyter.jupyterCommandLineArguments setting not working #9351

kjbrak opened this issue Mar 14, 2022 · 1 comment
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@kjbrak
Copy link

kjbrak commented Mar 14, 2022

Applies To

  • Notebooks (.ipynb files)
  • Interactive Window and/or Cell Scripts (.py files with #%% markers)

What happened?

The jupyter.jupyterCommandLineArguments setting can be set with some commands to be run during startup of the ipython terminal, but it is not working.

I would for example like to be able to do import dotenv and dotenv.load_dotenv() during start up of the interactive window to get some envornmental variables loaded in the interactive window environement. Nothing passed in a list to this setting works as expected.

A trivial example would be:
"jupyter.jupyterCommandLineArguments": [ "import pandas as pd" ],

This does not have any effect (irrespective of which package, f.ex. import dotenv, does not work either) is not available in the interactive window after startup/restart.

Ref. description in vscode settings GUI:
Jupyter: Run Startup Commands
A series of Python instructions or iPython magic commands. Can be either an array of strings or a single string with commands separated by '\n'. Commands will be silently executed whenever the interactive window loads. For instance, set this to '%load_ext autoreload\n%autoreload 2' to automatically reload changes made to imported files without having to restart the interactive session.

VS Code Version

1.65.2

Jupyter Extension Version

8.1.1

Jupyter logs

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
\InteractiveInput-1 in <cell line: 1>()
----> <a href='vscode-interactive-input:/InteractiveInput-1?line=0'>1</a> pd

NameError: name 'pd' is not defined

Coding Language and Runtime Version

Python v3.8.0

Language Extension Version (if applicable)

v2022.2.1924087327

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

N/A or Not sure

@kjbrak kjbrak added bug Issue identified by VS Code Team member as probable bug needs-triage labels Mar 14, 2022
@kjbrak kjbrak changed the title jupyter.jupyterCommandLineArguments settings not working jupyter.jupyterCommandLineArguments setting not working Mar 14, 2022
@rchiodo
Copy link
Contributor

rchiodo commented Mar 14, 2022

Thanks for the issue. You should be setting this setting:

"jupyter.runStartupCommands": []

The jupyter.jupyterCommandLineArguments is used when we start jupyter, it is not passed to the kernel.

For example, this is what you'd set it to based on the example in the docs:

"jupyter.runStartupCommands": [
    "%load_ext autoreload",
    "%autoreload 2"
]

You need to close and reopen a notebook for those changes to take effect.

@rchiodo rchiodo closed this as completed Mar 14, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

3 participants