草庐IT

fnon-call-exceptions

全部标签

python - 在 subprocess.call 中使用大于运算符

我想做的很简单。我想使用python的subprocess模块调用以下命令。cat/path/to/file_A>file_B该命令简单地工作并将file_A的内容复制到当前工作目录中的file_B。但是,当我尝试在脚本中使用subprocess模块调用此命令时,它会出错。以下是我正在做的:importsubprocesssubprocess.call(["cat","/path/to/file_A",">","file_B"])我收到以下错误:cat:/path/to/file_A:Nosuchfileordirectorycat:>:Nosuchfileordirectorycat

python异常<类型 'exceptions.ImportError'>没有名为gdb :的模块

我刚刚在运行linux的服务器计算机上从主目录中的源代码编译了gdb7.8。我之前一直在使用gdb7.6,除了gdb本身的稳定性问题(升级的原因)之外,一切正常。自从gdb升级后,当我运行cgdb0.6.7时,我立即收到以下消息:PythonExceptionNomodulenamedgdb:warning:CouldnotloadthePythongdbmodulefrom`/home/username/bin/gdb//python'.LimitedPythonsupportisavailablefromthe_gdbmodule.Suggestpassing--data-dire

Python 请求.exceptions.SSLError : EOF occurred in violation of protocol

我将从提供RESTfulJSONAPI的ABBG13网关检索一些信息。API通过https端点由网关托管。基本认证机制用于认证。然而所有的交通通过SSL层。在linux上使用命令:curl-s-k-XGET-uuser:passwordhttps://host/meters/a_serial/power一切顺利!我正在尝试使用Requests2.8.1和以下代码在Python2.7.10中为Windows编写脚本:importrequestsrequests.get('https://host/meters/a_serial/power',auth=('user','password'

python - Try-Except-Finally 语句的过时书籍描述

我正在关注Apress,从新手到专业的Python入门这本书。据说:finally.Youcanusetry/finallyifyouneedtomakesurethatsomecode(forexample,cleanupcode)isexecutedregardlessofwhetheranexceptionisraisedornot.Thiscodeisthenputinthefinallyclause.Notethatyoucannothavebothexceptclausesandafinallyclauseinthesametrystatement—butyoucanput

python - Python 中的递归?运行时错误 : maximum recursion depth exceeded while calling a Python object

这个问题在这里已经有了答案:WhatisthemaximumrecursiondepthinPython,andhowtoincreaseit?(19个回答)关闭8个月前。我的代码还有另一个问题。我正在用Vpython编写我的第一个程序,我必须模拟混合两种气体。首先,我遇到了边界问题,但是现在当球(代表气体粒子)停留在边界内时,就会出现不同的错误。几秒钟后,我收到一个错误,显示在我函数的源代码下方。代码:defMovingTheBall(listOfBalls,position,numCell,flagOfExecution):flag=0ifflagOfExecution==0:po

python - netcdf4-python : memory increasing with numerous calls to slice data from netcdf object

我正在尝试使用netcdf4-python从netcdf4文件中读取数据切片。这是第一次使用python,我遇到了内存问题。下面是代码的简化版本。在循环的每次迭代中,内存跳转相当于我读取的数据片。如何在遍历每个变量时清理内存?#!/usr/bin/envpythonfromnetCDF4importDatasetimportosimportsysimportpsutilprocess=psutil.Process(os.getpid())defprint_memory_usage():nr_mbytes=process.get_memory_info()[0]/1048576.0sys

python - django.core.exceptions.ImproperlyConfigured : 'django_mongodb_engine' isn't an available database backend

我无法正确运行djangomongo引擎。我在settings.py中的数据库条目是DATABASES={'default':{'ENGINE':'django_mongodb_engine','NAME':'local',}}我的pipfreeze结果是Django==1.8.2django-mongodb-engine==0.5.2djangotoolbox==1.6.2pymongo==3.0.2运行时出错pythonmanage.pyrunserver是django.core.exceptions.ImproperlyConfigured:'django_mongodb_eng

python - 如何使用 Python Suds(版本 0.3.6)SOAP 库 : TypeNotFound exception? 导入 XSD 模式

我正在尝试将SABRE旅行Web服务与PythonSuds结合使用,但是一个XSD似乎格式不正确(可能在此架构中缺少命名空间)。fromsuds.clientimportClientwsdl='http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/OTA_AirPriceLLSRQ.wsdl'client=Client(wsdl,cache=None)调试跟踪返回:.DEBUG:suds.wsdl:readingwsdlat:http://webservices.sabre.com/wsdl/sabreXML1.0.00/tpf/OT

c++ - 来自 SWIG PyObject_Call 段错误的 Python 回调

我有一个wx.py.Shell.shell小部件,它允许用户执行与我的程序交互的python代码。我希望能够将用户在此空间中定义的函数传递到我的C++代码(通过wxswig生成的围绕我的自定义小部件的包装器)并执行它。在我的C++代码中,我使用std::function类来调用绑定(bind)函数(C++或Python)所以我创建了一个简单的类来用函数调用运算符包装PyObject。但是,当我尝试调用PyObject*时出现段错误。classPyMenuCallback{PyObject*Func;public:PyMenuCallback(constPyMenuCallback&op

Python C API : how to get string representation of exception?

如果我这样做(例如)open("/snafu/fnord")在Python中(并且文件不存在),我得到一个回溯和消息IOError:[Errno2]Nosuchfileordirectory:'/snafu/fnord'我想用Python的CAPI(即嵌入在C程序中的Python解释器)获取上述字符串。我需要它作为一个字符串,而不是输出到控制台。使用PyErr_Fetch()我可以获得异常的类型对象和值。对于上面的例子,值是一个元组:(2,'Nosuchfileordirectory','/snafu/fnord')从我从PyErr_Fetch()获得的信息到Python解释器显示的字