我最近使用 更新了我的 python 版本从 3.8 到 3.10,
sudo update-alternatives --config python3但这似乎在某处导致了 apt 的问题。每当我尝试运行时,sudo apt-get update它都会按预期工作。当我尝试运行时sudo apt-get upgrade,我遇到了以下问题。
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up python-apt (2.0.0ubuntu0.20.04.6) ...
/var/lib/dpkg/info/python-apt.postinst: 6: …Run Code Online (Sandbox Code Playgroud) 我需要使用 Python 2.7 才能使用 PneumoCaT,因为它只能与 Python 2.7 一起运行,而不是更高版本。我试图在 Ubuntu 中将 Python 版本从 3.8 设置为 2.7,但我做不到。
这是我正在使用的代码。
ls /bin/python*
我有/bin/python2.7和/bin/python3.8
python --versionPython 3.8 出现了。
sudo update-alternatives --config python
我可以选择python 2和3。我选择了python2。
结果python --version仍然是Python 3.8。
我正在尝试使用以下步骤从远程( https://git.kernel.org/pub/scm/bluetooth/bluez.git )安装最新版本的 BlueZ :-
./bootstrap
./configure --disable-dependency-tracking
make
Run Code Online (Sandbox Code Playgroud)
但是,配置过程失败并出现以下情况:-
checking systemd user unit dir... /usr/lib/systemd/user
checking for rst2man... no
checking for rst2man.py... no
configure: error: rst2man is required
make: *** No targets specified and no makefile found. Stop.
Run Code Online (Sandbox Code Playgroud)
在网上快速搜索后,我发现为了满足这个要求,我必须安装 python-docutils,但这对我来说总是失败,如下所示
$ sudo apt -y install python-docutils
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python-docutils is not available, but is referred to by another package.
This may mean that the package is missing, has …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的环境中安装 python3 (和 python2),但我不断遇到以下问题:
sudo apt-get install python3
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3 is already the newest version (3.10.6-1~22.04).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up python3-minimal (3.10.6-1~22.04) ...
/var/lib/dpkg/info/python3-minimal.postinst: 5: py3compile: not found
dpkg: error processing package python3-minimal (--configure): …Run Code Online (Sandbox Code Playgroud) 所以,我正在用 GTK3 开发我的第一个应用程序,但我不知道如何将我的按钮与其各自的定义链接起来。任何人都可以发布教程,示例或一些文档吗?
使用接下来的东西来开发我的应用程序:
我正在开发的应用程序是Virtuam(App Showdown 的候选者!)
我有这个代码:
from sys import argv
import os
bold = "\033[1m"
reset = "\033[0;0m"
try:
argv[1]
except IndexError:
print("\nNo arguments! Add \"-h\" or \"--help\" for more info." + bold + "\n\nNow look what you've done!" + reset)
else:
pass
if argv[1] == "-h" or "--help":
print("\nxxxx, version 0.0.2")
print("xxxx is a simple tool for the command line used for quickly saving\n\
chunks of text, while providing more functionality than the traditional method\n\
(e.g. echo \"HELLO WORLD\" > hi.txt) used in bash.") …Run Code Online (Sandbox Code Playgroud) 我正在开发一个 PyGtk 应用程序,我想显示来自用户主题的 USB 记忆棒的图像。但是,我似乎无法确定图标的名称,Google 也无济于事。考虑以下代码:
import pygtk
pygtk.require('2.0')
require gtk
icon_theme = gtk.icon_theme_get_default()
icon_theme.has_icon('firefox') #True
icon_theme.has_icon('google-chrome') #True
icon_theme.has_icon('usb') #False. I have also tried "drive", and "usb-drive".
Run Code Online (Sandbox Code Playgroud)
***********更新2********************
尝试并成功使用 virtualenv 创建了一个虚拟环境。
[08:05 USER@system ~] > mkdir test_virtual
[08:05 USER@system ~] > virtualenv test_virtual/
New python executable in /home/USER/test_virtual/bin/python
Installing setuptools, pip, wheel...done.
[08:05 USER@system ~] > ls test_virtual/
bin include lib local pip-selfcheck.json
Run Code Online (Sandbox Code Playgroud)
***********更新1********************
根据这里的要求,是指向pip list和pip3 list的 pastebin 链接。
***********原来的******************
我使用 sudo pip install virtualenv 安装了 virtualenv,在阅读了这里的几个答案后,这实际上不是一个好习惯。当我尝试卸载它时(主要是因为我打算采用 anaconda 方式并且我不喜欢我不在系统上使用的额外污垢)我收到以下错误:
(09:20 USER@system ~) > sudo pip uninstall virtualenv
The directory '/home/USER/.cache/pip/http' or its parent directory is not owned by the current user and the …Run Code Online (Sandbox Code Playgroud) 如何在我的 gnome 终端中用 py3 替换 python2?将
alias python='python3'
Run Code Online (Sandbox Code Playgroud)
工作?谢谢!
我不知道如何将命令“show tunneled-node-mgr tunneled-nodes”的输出写入文件 output.txt…………我尝试了以下操作,但不起作用
import subprocess
f=open("output.txt","w")
subprocess.Popen("show tunneled-node-mgr tunneled-nodes",stdout=file)
Run Code Online (Sandbox Code Playgroud)
但我得到的错误是
File "1.py", line 3, in <module>
subprocess.Popen("show tunneled-node-mgr tunneled-nodes",stdout=file)
File "/usr/lib64/python2.6/subprocess.py", line 642, in __init__
errread, errwrite)
File "/usr/lib64/python2.6/subprocess.py", line 1238, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Run Code Online (Sandbox Code Playgroud)