草庐IT

library_path

全部标签

python - 奇怪的 `UnicodeEncodeError` 使用 `os.path.exists`

在网络应用程序(使用Flask)中,出现以下错误:Unabletoretrievethethumbnailforu'/var/data/uploads/2012/03/22/12Gerd\xb4sBanjoTrio1024.jpg'Traceback(mostrecentcalllast):File"/var/www/beta/env/lib/python2.7/site-packages/dblib-1.0dev3-py2.7.egg/dblib/orm/file.py",line169,inget_thumbnailifnotexists(filename):File"/usr/l

python - (Python) 值错误 : Program dot not found in path

我有以下问题:我在xUbuntu操作系统上,我正在尝试在Flask应用程序中使用networkx,我有以下代码:.....importnetworkxasnx......#Creatingandinitializinggraphobjectwhichisnetworkxobjecthosts_graph=get_networkx_graph_object()#Variable'coord'wherethecoordinatesforeachnodewillbestoredcoord=nx.pygraphviz_layout(hosts_graph,prog='dot')最后一行是第41

python - 导入错误 : DLL load failed : - when trying to import psycopg2 library

>>>importpsycopg2Traceback(mostrecentcalllast):File"",line1,inFile"C:\Python26\lib\site-packages\psycopg2\__init__.py",line60,infrom_psycopgimportBINARY,NUMBER,STRING,DATETIME,ROWIDImportError:DLLloadfailed:Theapplicationhasfailedtostartbecauseitsside-by-sideconfigurationisincorrect.Pleaseseethe

python - os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)) 是什么意思? Python

在几个SO的问题中,有这些行可以访问代码的父目录,例如os.path.join(os.path.dirname(__file__))returnsnothing和os.path.join(os.path.dirname(__file__))returnsnothingimportos,sysparentddir=os.path.abspath(os.path.join(os.path.dirname(__file__),os.path.pardir))sys.path.append(parentddir)我知道os.path.abspath()返回某物的绝对路径,而sys.path.a

python - 使用 Python Image Library 将一张图片切割成多张图片

我需要使用PIL将这张图片分成三部分,然后选择中间部分。我该怎么做?http://thedilbertstore.com/images/periodic_content/dilbert/dt110507dhct.jpg 最佳答案 假设您有一张像这样的很长的图片。现在你想把它切成更小的垂直位,因为它太长了。这是一个Python脚本,可以执行此操作。这对我为LaTeX文档准备非常长的图像很有用。from__future__importdivisionimportImageimportmathimportosdeflong_slice(i

python - 机器人框架 : access Robot's global variables from Python library code?

我有一些设置类型的全局变量,我希望能够从Python代码访问这些变量。例如:pybot--variableRESULTS_PATH:/wherever/this/pointstest.txt现在,我的模块logger.py文件需要知道results_path才能正确设置。我知道我可以用变量初始化记录器,比如***Settings***Librarylogger${RESULTS_PATH}然后在记录器中我将传递results_path:def__init__(self,results_path):#Whatever但是对我来说这样做的问题是我想从Python代码和测试用例中访问和使用记

Python 的 os.path 在希伯来语文件名上窒息

我正在编写一个必须移动一些文件的脚本,但不幸的是,os.path似乎不能很好地处理国际化。当我有以希伯来语命名的文件时,就会出现问题。这是目录内容的屏幕截图:(来源:thegreenplace.net)现在考虑遍历此目录中文件的代码:files=os.listdir('test_source')forfinfiles:pf=os.path.join('test_source',f)printpf,os.path.exists(pf)输出是:test_source\exTruetest_source\joeTruetest_source\mie.txtTruetest_source\__

python - os.path.exists() 用于路径中的文件?

我通常使用os.path.exists()在对文件执行任何操作之前检查文件是否存在。我遇到过这样一种情况,我正在调用配置的env路径中的可执行文件,因此可以在不指定abspath的情况下调用它。是否可以在调用文件之前检查文件是否存在?(我可能会求助于try/except,但首先我要寻找os.path.exists()的替代品)顺便说一句-我在Windows上执行此操作。 最佳答案 您可以获得PATH环境变量,并在路径中的每个目录中为.exe尝试“exists()”。但这可能会表现得很糟糕。查找notepad.exe的例子:impor

python - Matplotlib 给出错误 "OverflowError: In draw_path: Exceeded cell block limit"

我正在尝试使用具有100000000个数据点的matplotlib渲染图像,它会产生错误OverflowError:Indraw_path:Exceededcellblocklimit。它可以绘制的数据点数量是否有限制? 最佳答案 问题是后端Agg中点数的硬编码限制。尝试使用:importmatplotlibasmplmpl.rcParams['agg.path.chunksize']=10000或其他大值。您可以在此处找到问题和建议的解决方案:https://github.com/matplotlib/matplotlib/iss

python - 当我尝试安装 virtualenv 时,是什么导致了这个错误? IO错误 : [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/virtualenv.py'

我正在尝试使用以下命令安装虚拟环境:pipinstallvirtualenv但我收到以下错误:IOError:[Errno13]Permissiondenied:'/Library/Python/2.7/site-packages/virtualenv.py'我该如何解决这个问题? 最佳答案 乍一看,您似乎需要管理员权限才能在您的系统上安装软件包。尝试以管理员身份或您的操作系统同等身份启动pip。 关于python-当我尝试安装virtualenv时,是什么导致了这个错误?IO错误:[E