我正在尝试编译glib-2.32.1,因此我安装libffi-3.0.1到以下路径:
~/localroot/lib/
Run Code Online (Sandbox Code Playgroud)
并且头文件位于:
~/localroot/lib/libffi-3.0.11/include/
Run Code Online (Sandbox Code Playgroud)
但是,当我配置时:
~/tmp/build_alot/glib-2.32.1 $ ./configure --prefix=~/localroot
Run Code Online (Sandbox Code Playgroud)
我看到以下错误:
checking whether to cache iconv descriptors... no
checking for ZLIB... yes
checking for LIBFFI... no
configure: error: Package requirements (libffi >= 3.0.0) were not met:
No package 'libffi' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables LIBFFI_CFLAGS
and LIBFFI_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for …Run Code Online (Sandbox Code Playgroud) 我正在脚本中生成matplotlib数字,我可以在有或没有图形显示的情况下交替运行.我希望脚本能够自动调整:通过显示,它应该以交互方式显示数字,而没有显示,它应该只是将它们保存到文件中.
从没有正在运行的X服务器生成matplotlib图的问题的答案,我了解到可以使用Agg后端进行非交互式绘图.
所以我正在尝试使用此代码:
import matplotlib
try:
import matplotlib.pyplot as plt
fig = plt.figure()
havedisplay = True
except:
matplotlib.use("Agg")
import matplotlib.pyplot as plt
fig = plt.figure()
havedisplay = False
# do the plotting
if havedisplay:
plt.show()
else:
fig.savefig("myfig.png")
Run Code Online (Sandbox Code Playgroud)
这在带有显示器的情况下是例外的.但是,如果没有显示,则调用matplotlib.use无效,因为已经选择了显示.很明显我matplotlib.use之前应该打电话import matplotlib.pyplot,但后来我不知道如何测试显示器是否可用.
我也试过使用实验函数matplotlib.switch_backend而不是matplotlib.use,但这会产生RuntimeError.
有人知道如何使上述代码按预期工作,或者可以建议另一种方法来检测显示器是否可用于matplotlib?
我最近偶然发现了在虚拟环境中运行覆盖率测量的一些问题.我不记得过去的类似问题,也无法在网上找到解决方案.
基本上,当我尝试在virtualenv中运行测试套件时,它工作正常.但是,尽管我尝试使用coverage它,但由于缺少所需的模块而失败.基于StackOverflow上的一些答案,我检查了我的脚本并发现它coverage使用不同的解释器,即使从内部运行也是如此virtualenv.
以下是如何重现它:
$ virtualenv --no-site-packages venv
New python executable in venv/bin/python
Installing Setuptools................................................done.
Installing Pip.......................................................done.
$ source venv/bin/activate
(venv)$ echo 'import sys; print(sys.executable)' > test.py
(venv)$ python test.py
/home/tadeck/testground/venv/bin/python
(venv)$ coverage run test.py
/usr/bin/python
Run Code Online (Sandbox Code Playgroud)
问题是:如何coverage无缝地使用虚拟环境?我可以在sys.path系统范围内更改或安装所需的模块,但必须采用更清洁的方式.
我想知道是否可以将coverage.xml文件合并到1个文件中以查看HTML输出中的全局报告.
我的unit/functional tests运行是1命令和integration tests第二个命令.这意味着我的覆盖范围unit/functional tests被覆盖了unit tests.
如果我对这个问题有一些解决方案,那将是很好的,主要是通过将这些文件组合成1个文件.
python unit-testing code-coverage coverage.py python-coverage
我希望我的python脚本能够使用所有可用的RAM而不是更多(出于效率原因).我可以通过只读取有限数量的数据来控制它,但我需要知道在运行时有多少RAM是免费的才能做到这一点.它将在各种Linux系统上运行.是否可以在运行时确定空闲RAM?
我安装了python 3.1,并且我已将它添加到系统路径中.现在我可以打开"cmd"并键入python来启动python,但每当我尝试使用(shift +右键单击 - >打开命令提示符)在特定目录中打开cmd,并键入python时,它会显示"command not found "!
我怎样才能解决这个问题?
如果我想从中获得更好的性能,比如说MySQLdb,我可以自己编译它,我会得到更好的性能,因为它不是在i386,i486上编写的,只是在我的CPU上.此外,我可以选择编译选项等等......现在,我想知道对于非常规软件(例如编译器)是否也是如此.这是第一部分:
(是的,我知道,我可以编译我的编译器并对其进行基准测试......但也许......有人已经知道了答案,并将与我们分享=)
我正在尝试使用Python,GTK3和cairo创建一个简单的绘图应用程序.该工具应该有不同的刷子和某种高亮笔.我想我可以使用笔划的alpha属性来创建它.但是,连接点会重叠创建,从而产生奇怪的效果.
以下是负责此红色画笔和荧光笔模式的代码:
def draw_brush(widget, x, y, odata, width=2.5, r=1, g=0, b=0, alpha=1):
cr = cairo.Context(widget.surface)
cr.set_source_rgba(r, g, b, alpha)
cr.set_line_width(width)
cr.set_line_cap(1)
cr.set_line_join(0)
for stroke in odata:
for i, point in enumerate(stroke):
if len(stroke) == 1:
radius = 2
cr.arc(point['x'], point['y'], radius, 0, 2.0 * math.pi)
cr.fill()
cr.stroke()
elif i != 0:
cr.move_to(stroke[i - 1]['x'], stroke[i - 1]['y'])
cr.line_to(point['x'], point['y'])
cr.stroke()
cr.save()
Run Code Online (Sandbox Code Playgroud)
借助鼠标点击的代码:
def motion_notify_event_cb(self, widget, event):
point = {'x': event.x, 'y': event.y, 'time': time.time()}
if self.odata:
self.odata[-1].append(point)
if …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用shutil.copytree:
shutil.copytree(SOURCE_DIR, TARGET_DIR, ignore=None)
Run Code Online (Sandbox Code Playgroud)
此副本还包含文件夹中的文件.我只需要复制没有任何文件的文件夹.怎么做?
有似乎是一个max_length对CharField只.但是min_length对于a来说TextField(),有没有办法强制执行100个字符TextField?
python ×7
coverage.py ×2
gcc ×2
linux ×2
c ×1
cairo ×1
compilation ×1
django ×1
forms ×1
gtk3 ×1
linker ×1
matplotlib ×1
performance ×1
pycairo ×1
python-3.x ×1
shutil ×1
unit-testing ×1
virtualenv ×1
windows ×1