草庐IT

importances

全部标签

Python:使用 __import__ 时执行相对导入?

这里是这个测试中的文件:main.pyapp/|-__init__.py|-master.py|-plugin/|-|-__init__.py|-|-p1.py|-|_p2.py我们的想法是拥有一个支持插件的应用程序。可以将新的.py或.pyc文件放入符合我的API的插件中。我在应用程序级别有一个master.py文件,其中包含所有插件可能需要访问的全局变量和函数,以及应用程序本身。出于此测试的目的,“app”包含app/__init__.py中的测试函数。在实践中,应用程序可能会被移动到单独的代码文件中,但我只是在该代码文件中使用importmaster来引入对master的引用.文

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 - 导入错误 : 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

python - 为什么我在使用 Google Protocol Buffers 时会看到 "cannot import name descriptor_pb2"错误?

当使用我们的protobuf类生成的Python代码时,我们得到这个错误:cannotimportnamedescriptor_pb2等效的C++生成的代码工作得很好,所以看起来我们的实际原型(prototype)定义没有问题。当我尝试导入我们的类时出现此错误,如下所示:importsyssys.path.append('..\path\to\generated')sys.path.append('..\contrib\protobuf\python')fromfoobar_pb2importFooBar附加系统路径是否正确?我在protobuf\python\google\proto