小编not*_*ame的帖子

Python:Ctypes 如何检查内存管理

所以我使用 Python 作为前端 GUI,它与一些 C 文件交互以作为后端进行存储和内存管理。每当 GUI 的窗口关闭或退出时,我都会为分配的变量调用所有析构函数方法。

无论如何,在退出整个程序以确保没有任何内存泄漏之前,是否可以检查内存泄漏或可用性,例如 C Valgrind 检查?

示例退出:

from tkinter import *
root = Tk()  # New GUI
# some code here

def destructorMethods:
    myFunctions.destructorLinkedList()  # Destructor method of my allocated memory in my C file
    # Here is where I would want to run a Valgrind/Memory management check before closing
    root.destroy()  # close the program

root.protocol("WM_DELETE_WINDOW", destructorMethods)  # When the close window option is pressed call destructorMethods function

Run Code Online (Sandbox Code Playgroud)

c python ctypes valgrind memory-management

9
推荐指数
1
解决办法
377
查看次数

未找到 Ubuntu 18.04 命令“pyenv”,您的意思是:

所以这是我的 Ubuntu 版本:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.2 LTS
Release:        18.04
Codename:       bionic
Run Code Online (Sandbox Code Playgroud)

我正在尝试运行以下命令:pyenv install 3.6.2但出现错误:

Command 'pyenv' not found, did you mean:
  command 'pyvenv' from deb python3-venv
  command 'p7env' from deb libnss3-tools 
Run Code Online (Sandbox Code Playgroud)

我已经搜索过了,这篇文章(Ubuntu 14.04 - Python 3.4 - pyenv: command Not Found)指出 Ubuntu 14.04 及以下默认使用 Python 2,因此必须使用 Python 2 virtualenv,但为什么我的 18.04 Ubuntu 无法识别该命令?

python ubuntu pyenv ubuntu-18.04

4
推荐指数
1
解决办法
7642
查看次数

Ubuntu:_tkinter.TclError:没有显示名称,也没有 $DISPLAY 环境变量

因此,我尝试在 Windows 10 上使用 tkinter 从 Ubuntu 命令行运行 python GUI,并收到以下错误:

brandon@DESKTOP-V5LTF5T:~$ python3 MainApp.py
Traceback (most recent call last):
  File "MainApp.py", line 14, in <module>
    root = tk.Tk()
  File "/usr/lib/python3.6/tkinter/__init__.py", line 2023, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable
Run Code Online (Sandbox Code Playgroud)

如果您正在使用该matplotlib库,请使用以下问题:_tkinter.TclError:没有显示名称并且没有 $DISPLAY 环境变量

但是,这个问题tkinter仅适用于使用图书馆的人

python ubuntu tkinter

1
推荐指数
1
解决办法
1万
查看次数