Home > front end >  Why is python importing `scipy` even though I haven't asked it to?
Why is python importing `scipy` even though I haven't asked it to?

Time:12-22

I have a file constants.py from which I want to import a constant SEED.

When I run

from constants import SEED

I get

ImportError: cannot import name 'SEED' from 'scipy.optimize._highs.constants' 
(/opt/conda/envs/rapids/lib/python3.7/site-packages/scipy/optimize/_highs/constants
.cpython-37m-x86_64-linux-gnu.so)

I would understand this if my file was called scipy/optimize/_highs/constants.py but constants.py is in my local dir.

Also, why is python looking several layers deep in scipy? How is it getting from constants import SEED and from scipuy.optimize._highs.constants import SEED mixed up?

I am running code on the RAPIDS Paperspace gradient image.

My sys.path

['/notebooks/TPS-12/analysis', # The dir my notebook   constants.py is in
 '/opt/conda/envs/rapids/lib/python37.zip',
 '/opt/conda/envs/rapids/lib/python3.7',
 '/opt/conda/envs/rapids/lib/python3.7/lib-dynload',
 '',
 '/opt/conda/envs/rapids/lib/python3.7/site-packages',
 '/opt/conda/envs/rapids/lib/python3.7/site-packages/IPython/extensions',
 '/root/.ipython']

CodePudding user response:

If you've recently updated your IDE, have you tried to update scipy? I know that's what I had to do when I was using Anaconda. Even if you're using a different IDE it's worth a shot.

Additionally, there might be relevant information here. To summarize, try renaming your "constants" module to something else.

CodePudding user response:

I was running scipy version 1.6.0 but once I ran conda update scipy it fixed the problem.

Weirdly enough though that didn't actually update my scipy version. But it installed a bunch of updates and removed some (seemingly unconnected?) libraries like seaborn

  • Related