Skip to content

Notebook sets PYTHONPATH via sys.path.append #4104

@fredm73

Description

@fredm73

I am reporting a bug. At the start of this experiment, my Windows PYTHONPATH environment variable is not set.
When, in Spyder, I execute '_sys.path.append("D:\Documents\Courses\fastaiMachineLearning\ml1\fastai")' the PYTHONPATH remains unset (as it should). Things work fine in my Spyder session and subsequent ones.

When in Jupyter notebook, I execute the same 'sys.path' statement, my PYTHONPATH is set (by Jupyter, I guess). This is unfortunate, because I have a module
'IO.py' in the fastai folder. Now, when I execute the Anaconda prompt I get

Fatal Python error: init_sys_streams: can't initialize sys standard streams
Traceback (most recent call last):
  File "D:\Documents\Courses\fastaiMachineLearning\ml1\fastai\io.py", line 1, in <module>
ImportError: attempted relative import with no known parent package

I get the same error now when starting up anything else that uses Python (like Spyder).

Now, when I remove the environment variable PYTHONPATH from Windows things work fine again.
I believe it is a bug for the PYTHONPATH to be set (by Juypter notebook via the sys.path.append). How can I set the sys.path temporarily in the notebook without the environment variable being set?

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