I have a conda
environment, in a bash terminal, with an Intel Python Distribution interpreter. However, when importing packages, they are imported from what loo
There appears to be (or have been) another Python 3.6 in the PATH
, and I suspect that somehow the Conda dependency resolver ended up resolving some packages to this alternative site-packages
and inadvertently including this directory in sys.path
. This appears to be a known issue.
The reason I believe this is because the pandas
module is being loaded from here:
/home/torstein/.local/lib/python3.6/site-packages/pandas
If you check in Python
import sys
sys.path
I expect that this should show the above directory.
Since it was reported that PYTHONPATH
is empty (as it should be!), that can't be responsible for this misloading, hence I think it was Conda that somehow configured the env this way.
Also, the fact that your Python 3.7 env is unaffected is likely because you can't load modules across different minor versions.
Somehow you need to get rid of that dependency. There are a few things to try
/home/torstein/.local/
from your PATH
. This could cause other issues though. Presumably you have it in PATH
because you have other non-development things in there.site-packages
directory. In comments, it was stated that this is residual from a global Python installation no longer in use, so it seems like a good thing to just get rid of. Do back it up, though, in case there are other dependencies on it.sys.path
before importing modules. Not sure of a clean way to do this.Personally, I'd want to delete it and create new envs. It can be hard to know how tied into this directory you are, so I'd be wary of assuming that other packages don't somehow have hidden dependencies on what is in there.
The recommended workaround from the GitHub issue is to add the following environment variable,
export PYTHONNOUSERSITE=True
which prevents Conda from loading other local site-packages
directories. With this, you shouldn't have encountered the problem in the first place.