草庐IT

current_module

全部标签

python - 用于 Python 的 OpenCV - AttributeError : 'module' object has no attribute 'connectedComponents'

我正在使用以下OpenCV教程尝试分水岭算法:https://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_imgproc/py_watershed/py_watershed.html#watershed我已经修复了一个错误,现在代码如下所示:importnumpyasnpimportcv2frommatplotlibimportpyplotaspltfromsysimportargvimg=cv2.imread(argv[1])gray=cv2.cvtColor(img,cv2.COLOR_BGR2G

python - 动态地向 Python 模块添加函数

我们的框架需要将某些功能包装在一些丑陋的样板代码中:defprefix_myname_suffix(obj):defactual():print'helloworld'obj.register(actual)returnobj我想这可以用装饰器来简化:@registerdefmyname():print'helloworld'然而,事实证明这相当棘手,主要是因为框架在模块级别寻找特定的函数名称模式。我在装饰器中尝试了以下方法,但无济于事:current_module=__import__(__name__)new_name=prefix+func.__name__+suffix#met

Python pocketsphinx RequestError : missing PocketSphinx module: ensure that PocketSphinx is set up correctly

我正在尝试制作一个Python应用程序,它可以使用PyAudio、SpeechRecognition和PocketSphinx录制音频并将其翻译成英文文本。我在MacOSXElCapitan版本10.11.2上运行。遵循类似thisone的教程和其他人,我已经下载了PyAudio版本0.2.9、SpeechRecognition以及PocketSphinx。我已经将它们安装到Conda环境中。我已按照此site中的说明进行操作在我的OSX上使用brewinstallswiggitpython,希望它能有所帮助。这是我的代码:#Loadpackagesimportspeech_recog

python - 错误 : each element of 'ext_modules' option must be an Extension instance or 2-tuple

我试图在python中使用setuptools创建一个egg包,但我得到了这个奇怪的错误:error:eachelementof'ext_modules'optionmustbeanExtensioninstanceor2-tuple我该如何解决这个问题? 最佳答案 我不得不重新排序导入语句以消除此错误。此代码生成错误:fromCython.Buildimportcythonizefromsetuptoolsimportfind_packages,setup此代码不会产生错误:fromsetuptoolsimportfind_pac

python - AttributeError : module object has no attribute "Series". 代码在 iPython 中有效

子模块不是隐式导入的,必须显式声明,但我正在显式调用pd.Series子模块,不是吗?无论如何,importpandasaspd难道不应该允许调用pd.Series吗?以下代码在iPython中完美运行,但在从脚本执行时失败。#!/usr/bin/env/python2.7#-*-coding:utf-8-*-importpandasaspdimportnumpyasnpcounts=pd.Series([632,1638,569,115],index=["Firmicutes","Proteobacteria","Actinobacteria","Bacteroidetes"])结果

python - 导入错误 : No module named backend_tkagg

我有这样的导入和代码:importpandasaspdimportnumpyasnpimportstatsmodels.formula.apiassmimportmatplotlib.pyplotasplt#ReadthedatafrompydatasetsrepousingPandasurl='./file.csv'white_side=pd.read_csv(url)#Fittingthemodelmodel=sm.ols(formula='budget~article_size',data=white_side,subset=white_side['producer']=="Pe

python - 如何解决 ImportError : No module named 'dbus' ?

我在我的ubuntu上安装了anaconda4,我的Python上有这些模块:dbus-python(1.2.4)gi(1.2)pydbus(0.2)QtAwesome(0.3.2)qtconsole(4.2.0)QtPy(1.0)sip(4.18)我尝试安装dbus-python(1.2.4)和pydbus(0.2),但是,它们都不起作用!在python3.5.1中测试一个简单的程序后,出现错误:importdbussystem_bus=dbus.SystemBus()ImportError:Nomodulenamed'dbus'当我在Python2.7.11和3.5.1中使用pyd

python - 狮身人面像 : list of functions in a module

我有一些python模块,主要包含函数和一些类。每一个都在单独的第一个文件中使用sphinx-autodoc进行记录。我想做的是在每个页面的顶部创建一个表或模块内容列表,例如,mymodule.py是deffirst():'Firstfunction'defsecond():'Secondfunction'而mymodule.rst是PageContents-------------:create_page_contents_list:Members-------..automodule::mymodule:members:那么输出应该是这样的:PageContents--------

Python + ZMQ : Operation cannot be accomplished in current state

我试图让一个python程序通过zeromq使用请求-回复模式与另一个python程序通信。客户端程序应向服务器程序发送请求,服务器程序进行回复。我有两台服务器,当一台服务器出现故障时,另一台服务器接管。当第一台服务器工作时,通信工作完美,但是,当第一台服务器发生故障并且当我向第二台服务器发出请求时,我看到错误:zmp.error.ZMQError:Operationcannotbeaccomplishedincurrentstate服务器1的代码:#RuntheserverwhileTrue:#Definethesocketusingthe"Context"sock=context.

python - gevent 库 : "Import Error: no module named greenlet"

大家好,我下载了一个需要geventpython库的脚本,每次运行该脚本时,它都会显示:File"shodan.py",line7,infromgeventimportmonkeyFile"C:\Python27\lib\site-packages\gevent\__init__.py",line48,infromgevent.greenletimportGreenlet,joinall,killallFile"C:\Python27\lib\site-packages\gevent\greenlet.py",line6,infromgevent.hubimportgreenlet,g