草庐IT

Import-Package

全部标签

python - 当 import_array 不在同一翻译单元中时出现段错误

我在正确初始化NumPyCAPI时遇到问题。我想我已经将问题隔离到从不同的翻译单元调用import_array,但我不知道为什么这很重要。最小工作示例:header1.hpp#ifndefHEADER1_HPP#defineHEADER1_HPP#include#include#includevoidinitialize();#endiffile1.cpp#include"header1.hpp"void*wrap_import_array(){import_array();return(void*)1;}voidinitialize(){wrap_import_array();}fi

c++ - 嵌入python报错Import by filename is not supported

我正在尝试将python嵌入到我的应用程序中,但很早就卡住了。我正在将Python嵌入到我的C++应用程序中并使用本教程中的代码:http://docs.python.org/2/extending/embedding.html#pure-embedding我的应用程序完全匹配并且编译成功没有错误。但是在运行应用程序pModule=PyImport_Import(pName);行失败返回0意味着我从PyErr_Print()得到错误输出Failedtoload"C:\Users\workspace\dpllib\pyscript.py"ImportError:Importbyfilen

python - 从 matplotlib 导入样式 ImportError : cannot import name 'style'

我收到以下错误信息ImportError:cannotimportname'style'当我运行时frommatplotlibimportstyle我正在使用ubuntu并尝试使用python3和python运行它。我安装了matplotlib版本(1.3.1),这是apt-get安装的最新版本。我已经安装了numpy并使用python3安装了matplotlib。没有快乐。有没有其他人遇到同样的问题? 最佳答案 sudopipinstall--upgradematplotlib成功了。尽管在我的机器上它最初抛出了一些问题。对于遇到

python - PackageNotInstalledError : Package is not installed in prefix

conda更新conda>>成功condaupdateanaconda>>给我一个错误,说packageisnotinstalledinprefix.我的系统上只安装了Python发行版。我该如何解决这个问题?(base)C:\Users\asukumari>condainfoactiveenvironment:baseactiveenvlocation:C:\Users\asukumari\AppData\Local\Continuum\anaconda3shelllevel:1userconfigfile:C:\Users\asukumari\.condarcpopulatedco

python - 导入 Python 模块时 __package__ 为 None

我想通过以下方式动态导入模块:我创建了一个名为pkg的文件夹,结构如下:pkg|__init__.py|foo.py在__init__.py的头部,添加如下代码片段:pkgpath=os.path.dirname(pkg.__file__);formoduleinpkgutil.iter_modules([pkgpath]):__import__(module[1],locals(),globals());m=sys.modules[module[1]];printm.__package__;我发现m.__package__是None以防foo.py中没有导入语句但是如果我像这样添加一

python - 导入错误 : Failed to import the Cloud Firestore library for Python

尝试在python服务器上集成GooglefirestoreAPI...File"/home/daffolap-355/repos/subscriptions/appvendor/firebase_admin/firestore.py",line28,inraiseImportError('FailedtoimporttheCloudFirestorelibraryforPython.Makesure'ImportError:FailedtoimporttheCloudFirestorelibraryforPython.Makesuretoinstallthe"google-cloud

python - 我必须安装什么来解决 Could not find any typelib for GtkSource, Cannot import : GtkSourceView, cannot import name GtkSource

我正在尝试为来自https://bugzilla.gnome.org/show_bug.cgi?id=680569的meld应用补丁我自己,我遇到了这个问题:$gitclonegit://git.gnome.org/meld$cdmeld$pythonsetup.pybuild$bin/meld2014-01-1116:30:44,736ERRORroot:CouldnotfindanytypelibforGtkSourceCannotimport:GtkSourceViewcannotimportnameGtkSource我对Python知之甚少,例如不知道(还)什么是Python的

python - 在ubuntu上导入caffe时ImportError cannot import name BytesIO

我正在尝试制作caffe在我的机器上运行Ubuntu12.04LTS。完成Installationpage上的所有步骤后,我成功地训练了LeNet模型并尝试将其用作here的教程.然后我得到以下错误:Traceback(mostrecentcalllast):File"",line1,inImportError:NomodulenamedcaffeErrorinsys.excepthook:Traceback(mostrecentcalllast):File"/usr/lib/python2.7/dist-packages/apport_python_hook.py",line66,i

python - Django 休息 : The view does not want to import

我正在使用Django教程RestFramework(http://www.django-rest-framework.org/tutorial/1-serialization)进行练习我正处于创建URL的阶段,但在访问View时遇到了问题。我执行代码:importsnippetsfromviews我无法导入View,将收到:'module'objecthasnoattribute'snippet_list'我的代码View:from.modelsimportSnippetfromserializersimportSnippetSerializerfromrest_framework.

python - Django : Can't import 'module' . 检查模块AppConfig.name是否正确

可能看起来像是一个已经回答过的问题,实际上here你和我有同样的问题(有点)。我的问题是,这只是一个技巧,一行,没有解释(它仍然不同,但给出的解决方案有效,这是我问题的一部分)。这是我的项目结构,经过简化:manage.pycompfactu/---settings.py|--__init__.py|--core/--------__init__.py|-apps.py下面是我在INSTALLED_APPS中添加我的应用程序的方式:apps.pyfromdjango.appsimportAppConfigclassCoreConfig(AppConfig):name='core'set