Skip to content

PYTHONSTARTUP rc file is run when ipdb is imported in non-interactive mode #9949

Open

Description

@alanbernstein

My understanding is that the PYTHONSTARTUP file is intended solely for use in the interactive prompt. This page is a little ambiguous, but does seem to support that: https://docs.python.org/2/using/cmdline.html#environment-variables

This is happening for me on OS X 10.11.5, with brew installed python 2.7.12, python 3.5.2, ipython 5.0.0.

More details here: http://stackoverflow.com/questions/38781067/why-is-my-pythonrc-file-being-run-in-non-interactive-programs/38814182

Activity

  1. takluyver commented on Feb 20, 2017

    @takluyver
    Member

    ipdb is setting up the entire IPython application when it's imported in order to read IPython's config. That will result in startup files being run. If you want to report it to ipdb, I think they can avoid it by configuring:

    c.InteractiveShellApp.exec_PYTHONSTARTUP = False

    Or, to prevent other startup code executing, subclass TerminalIPythonApp and override the methods:

    self._run_startup_files()
    self._run_exec_lines()
    self.run_exec_files()
  2. added this to the not ipython milestone on Feb 20, 2017
  3. alanbernstein commented on Feb 20, 2017

    @alanbernstein
    Author

    Thanks for the info, I didn't realize ipdb was distinct from ipython.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions