0

I created a new conda environment myenv and the only package I installed is the uncommon package astropy. I ran jupyter notebook out of this activated environment myenv, just to see that myenv isn't activated and I need the package nb_conda to activate it, which I then installed. Now its possible for me to select and activate myenv and to import the aforesaid package. However, if I switch to any other environment ("Change kernel"), then the package astropy is still loaded, eventhough it is not installed.

Now Im thinking that the kernel wasn't switched afterall. But this also cannot be, since it's not possible for myenvto load any other package of another environment.

What am I missing?

Cheers

EDIT 1: I just noticed: whenever I run the aforesaid package in the base (?) environment Python3, then a hidden directory .astropy is created in my home path C:\Users\me\. In this hidden directory I can see two .cfg-files. Maybe this all has something to do with my question?

Why at all is this hidden directory created? Does every python package create such a hidden folder?

MJimitater
  • 833
  • 3
  • 13
  • 26
  • 1
    You seem to have assimilated some misinformation about how to use Jupyter with Conda. Please read the information in [Conda environments not showing up in Jupyter Notebook](https://stackoverflow.com/questions/39604271/conda-environments-not-showing-up-in-jupyter-notebook), in particular [this answer](https://stackoverflow.com/a/43197286/570918). You should not be activating the kernel environment. Instead, keep a dedicated Jupyter environment with `nb_conda_kernels` installed and always launch from there. `nb_conda` is irrelevant to your problem and is not required. – merv Oct 27 '20 at 16:28
  • Thank you @merv for hinting that! It sure works now with `nb_conda_kernels` installed. The only thing that still confuses me is why other kernels, that are switched to in jupyter notebook, can import a package that the don't have? – MJimitater Oct 28 '20 at 08:23
  • 1
    Packages from other identically versioned Python installations (other envs, system- or user-level Python) can leak into a current env through environment variables like `PATH` and `PYTHONPATH`. I would check things like `import sys; print(sys.path)` or, in the case of a particular package, `import astropy; print(astropy.__spec__)`, to track down exactly where Python is loading things from. Considering adding that info to your question. – merv Oct 29 '20 at 19:08

0 Answers0