简体   繁体   English

为什么即使我没有要求 python 导入`scipy`?

[英]Why is python importing `scipy` even though I haven't asked it to?

I have a file constants.py from which I want to import a constant SEED .我有一个文件constants.py ,我想从中导入一个常量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.如果我的文件被称为scipy/optimize/_highs/constants.pyconstants.py在我的本地目录中,我会理解这一点。

Also, why is python looking several layers deep in scipy?另外,为什么 python 在 scipy 中看起来有好几层? How is it getting from constants import SEED and from scipuy.optimize._highs.constants import SEED mixed up?它是如何from constants import SEEDfrom scipuy.optimize._highs.constants import SEED混合起来的?

I am running code on the RAPIDS Paperspace gradient image.我正在 RAPIDS Paperspace 渐变图像上运行代码。

My sys.path我的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']

If you've recently updated your IDE, have you tried to update scipy?如果您最近更新了 IDE,您是否尝试过更新 scipy? I know that's what I had to do when I was using Anaconda.我知道这是我在使用 Anaconda 时必须做的。 Even if you're using a different IDE it's worth a shot.即使您使用不同的 IDE 也值得一试。

Additionally, there might be relevant information here .另外,这里可能有相关信息。 To summarize, try renaming your "constants" module to something else.总而言之,尝试将您的“常量”模块重命名为其他内容。

I was running scipy version 1.6.0 but once I ran conda update scipy it fixed the problem.我正在运行 scipy 版本 1.6.0 但是一旦我运行conda update scipy它就解决了问题。

Weirdly enough though that didn't actually update my scipy version.奇怪的是,这实际上并没有更新我的 scipy 版本。 But it installed a bunch of updates and removed some (seemingly unconnected?) libraries like seaborn但它安装了一堆更新并删除了一些(似乎未连接?)库,如 seaborn

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我的Flask应用未配置为重定向一条路由? - Why does my Flask app redirect one route even though I haven't configured it to? 为什么我的按钮可以工作,即使我没有为其分配任何父窗口? - Why is my button working even though I haven't assigned any parent window to it? 为什么即使我没有使用任何“str”命名变量,我也会收到(“str”函数不可调用)错误? - Why am I getting ('str' function is not callable) error even though I haven't used any 'str' named variable? 为什么python即使没有定义我的对象也能识别它? - Why does python recognise my object even when I haven't defined it? 为什么python认为我没有定义我的变量? - Why does python think I haven't defined my variables? 不断在PyCharm中获取“Project Files Changed”消息,即使我没有更改项目中的任何文件 - Constantly getting “Project Files Changed” messages in PyCharm, even though I haven't changed any of the files in my project 为什么即使我没有显式使用plt.show函数,此对象仍显示功能? - Why does this object display function even if I haven't explicitly used plt.show function? 为什么导入scipy后不能使用scipy.linalg? - Why can't I use scipy.linalg after importing scipy? 即使我安装了 Flask 也没有导入 - Flask is not importing even though I installed it 我无法导入pylab-即使已经安装了matplotlib,numpy和scipy(Python) - I cannot import pylab - even though matplotlib, numpy and scipy are already installed (Python)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM