草庐IT

import_meta_graph

全部标签

python - 在 python 中使用 absolute_import 和处理相对模块名称冲突

我真的希望这是我对复杂的Python2导入机制不理解的简单案例。我有以下设置:$>ls-ltrpypackage1total3-rw-r--r--1pelsonpelson0Aug1719:20io.py-rw-r--r--1pelsonpelson0Aug1719:20__init__.py-rw-r--r--1pelsonpelson57Aug1719:22code.py$>catpypackage1/code.pyfrom__future__importabsolute_importimportzipfile即我只有一个stub包,其中包含一个空的__init__.py和io.p

python - 导入错误 : cannot import name 'logsumexp' when importing sklearn. model_selection

我试图在python3.5的anaconda环境下用JupiterNotebook导入sklearn.model_selection,但我被警告说我没有“model_selection”模块,所以我做了conda更新scikit-learn。之后,我在导入sklearn.model_selection时收到了ImportError:cannotimportname'logsumexp'的消息。我重新安装了sklearn和scipy,但仍然收到同样的错误信息。我可以提点建议吗? 最佳答案 我刚才遇到了完全相同的问题。在我更新了scik

python 3.5 在 statsmodels ImportError : cannot import name '_representation'

当我这样做时,我无法设法正确导入statsmodels.api,我遇到了这个错误:File"/home/mlv/.local/lib/python3.5/site-packages/statsmodels/tsa/statespace/tools.py",line59,inset_modefrom.import(_representation,_kalman_filter,_kalman_smoother,ImportError:cannotimportname'_representation'我已经尝试重新安装或更新它,但没有改变。请我需要帮助=) 最佳答

python - 适当的相对进口 : "Unable to import module"

我有一个结构如下的项目:.└──myapp  ├──app.py  ├──models  │  ├──hello.py  │  └──world.py  └──requirements.txt我有两个模型,hello和world。这两个模型都是从app.py中使用的,我在其中像这样导入它们:frommodels.helloimportHellofrommodels.worldimportWorld但是world也需要用到hello。我在world.py中试过这个:frommodels.helloimportHello当我运行应用程序时,上面的技术在技术上是有效的,但是VSCode的Py

python - 导入错误 : cannot import name 'transfer_markers' when testing with pytest

当我通过运行以下命令为我的python项目运行测试时:pythonsetup.pytest(or)pytestproject_name我收到以下错误:.../project_name/.eggs/pytest_asyncio-0.9.0-py3.6.egg/pytest_asyncio/plugin.py",line8,infrom_pytest.pythonimporttransfer_markersImportError:cannotimportname'transfer_markers' 最佳答案 当我在网上查找时,几乎没有任

python - "import safe"在 Python 中是什么意思?

我刚刚发现nose不会运行标记为可执行的测试的行为(如apreviousquestion中所述)。我发现这令人惊讶,在我了解nose的行为之前,我浪费了一些时间试图找出为什么nose没有运行我的测试。在nosetests的联机帮助页中,它描述了一个覆盖默认行为的选项:--exeLookfortestsinpythonmodulesthatareexecutable.Normalbehavioristoexcludeexecutablemodules,sincetheymaynotbeimport-safe[NOSE_INCLUDE_EXE]我的问题是:“导入安全”是什么意思?什么是非导

python - 为什么 "import"与 "import *"有区别?

"""modulea.py"""test="Iamtest"_test="Iam_test"__test="Iam__test"=============~$pythonPython2.6.2(r262:71600,Apr162009,09:17:39)[GCC4.0.1(AppleComputer,Inc.build5250)]ondarwinType"help","copyright","credits"or"license"formoreinformation.>>>fromaimport*>>>test'Iamtest'>>>_testTraceback(mostrecentc

python - 为什么会出现 TypeError : 'module' object is not callable when trying to import the random module?

我正在使用Python2.6并尝试运行一个简单的随机数生成器程序(random.py):importrandomforiinrange(5):#randomfloat:0.0我现在收到以下错误:C:\Users\Developer\Documents\PythonDemo>pythonrandom.pyTraceback(mostrecentcalllast):File"random.py",line3,inimportrandomFile"C:\Users\Developer\Documents\PythonDemo\random.py",line8,inprintrandom.ra

python - "from ... import ..."是什么意思?

fromsysimportargvfromos.pathimportexistsscript,from_file,to_file=argvprint"Copyingfrom%sto%s"%(from_file,to_file)#wecouldtwoononelinetoo,how?input=open(from_file)indata=input.read()print"Theinputfileis%dbyteslong"%len(indata)print"Doestheoutputfileexist?%r"%exists(to_file)print"Ready,hitreturnto

python - 通过导出器和 tf.train.write_graph() 保存模型之间的 tensorflow 区别?

保存模型有什么区别使用tensorflowserving中指定的导出器:例如:fromtensorflow.contrib.session_bundleimportexporter#fromtensorflow_serving.session_bundleimportexportersaver=tf.train.Saver(sharded=True)model_exporter=exporter.Exporter(saver)model_exporter.init(sess.graph.as_graph_def(),named_graph_signatures={'inputs':ex