标签: python3

如何让python等待程序停止后再执行下一行代码

我正在用 python 创建一个脚本,它将打开一个程序,然后 python 将等待该程序自行关闭,然后再继续执行下一个代码。这是我的脚本:

Import subprocess as sp
sp.Popen([r'C:/Folder/folder/a.exe'])
??????
????????
print("test")
Run Code Online (Sandbox Code Playgroud)

问号是我不知道的事情。

python3 selenium

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

ModuleNotFoundError:安装python 3.7后没有名为“apt_pkg”的模块

我最近使用以下命令在 Ubuntu 18.04.4 LTS 机器上安装了 python 3.7:

sudo apt-get install python3.7
Run Code Online (Sandbox Code Playgroud)

我还运行了以下命令,因为我希望 python 3.7 运行为python3

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1
Run Code Online (Sandbox Code Playgroud)

随后我按照一个建议来运行这个:

sudo apt autoremove
Run Code Online (Sandbox Code Playgroud)

现在,当我尝试启用universe存储库 ( add-apt-repository universe) 时,出现以下错误:

Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 11, in <module>
    from softwareproperties.SoftwareProperties import SoftwareProperties, shortcut_handler
  File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 28, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
Run Code Online (Sandbox Code Playgroud)

我找到的大多数答案都告诉我python3-apt这里这里一样重新安装,但这不起作用。

我还能尝试什么?

编辑:

这里这里还有一些建议,特别是指向 python 的 …

apt python3 18.04

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

ModuleNotFoundError:没有名为“tkinter”的模块

当我尝试使用该类时,出现了上述错误Turtle。我正在学习一个教程,它用于在屏幕上弹出一个窗口。代码很简单:

from turtle import Turtle, Screen
jabba = Turtle()
print(jabba)

my_screen = Screen()
print(my_screen.canvheight)
my_screen.exitonclick()
Run Code Online (Sandbox Code Playgroud)

但在终端中它说:

ModuleNotFoundError: No module named 'tkinter'
Run Code Online (Sandbox Code Playgroud)

我在 Ubuntu 20.04 上使用 PyCharm 专业 IDE。

python3 pycharm 20.04

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

无法安装 .sh 文件

我正在尝试使用一个名为 mgl-tools 的包,当我运行 ./install.sh 时,它不起作用。几天前它曾经有效。

错误:

./install.sh 
Installing MGLTools to /home/aka/Desktop/Expt 10/mgltools_x86_64Linux2_1.5.7
Installing Python Interpreter to 
tar (child): /home/aka/Desktop/Expt: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
Error in Python installation
Run Code Online (Sandbox Code Playgroud)

.sh文件的内容:

#!/bin/sh

# MGL Tools installation script
pythonargs=" "
pyoptimize=0
TarDir=`pwd`
export MGL_ROOT=""

# Parse the command-line arguments
opts=`getopt "hlc:d:" "$@"`
if [ "$?" != 0 ]
then
   echo "Usage: …
Run Code Online (Sandbox Code Playgroud)

python command-line tar python3 sh

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

在Ubuntu 23.04上安装Python3.10

我尝试在 Ubuntu 23.04 上将 python3.10 与本机 python3.11 一起安装,但看起来不可用。

mika@system:~$ sudo apt update && sudo apt install python3.10
Hit:1 http://ru.archive.ubuntu.com/ubuntu lunar InRelease
Get:2 http://ru.archive.ubuntu.com/ubuntu lunar-updates InRelease [109 kB]
Hit:3 https://repo.yandex.ru/yandex-browser/deb stable InRelease          
Get:4 http://ru.archive.ubuntu.com/ubuntu lunar-backports InRelease [99.8 kB]
Get:5 http://security.ubuntu.com/ubuntu lunar-security InRelease [109 kB] 
Fetched 317 kB in 1s (295 kB/s)    
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done …
Run Code Online (Sandbox Code Playgroud)

package-management python apt python3 23.04

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

python3的sklearn安装错误

当我运行命令时 sudo pip3 install -U scikit-learn

我收到一个奇怪的错误。

Cleaning up...
Command /usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/scikit-learn/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-hrwadcyq-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/scikit-learn
Storing debug log for failure in /home/donbeo/.pip/pip.log
Run Code Online (Sandbox Code Playgroud)

这里是日志文件的链接。 https://drive.google.com/file/d/0B3FIuCA5bZUaUC1pd21MTUFxWkU/edit?usp=sharing

我不知道如何解决这个问题。

python3 software-installation 14.04

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

How to install python3-dateutil in Ubuntu 12.04 (Precise)?

我正在尝试使用 将软件包安装python3-dateutil在 Ubuntu 12.04.4 LTS(精确)中aptitude,但我在任何地方都找不到它。我该如何安装?

aptitude python3

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

将 python3.4 设置为默认值后,Dropbox 和 Ubuntu 软件中心不起作用

在 Ubuntu 14.04 中,我设置python3.4为默认python版本。之后,Dropbox 不会在启动时启动,Ubuntu 软件中心也无法再打开。从命令行运行它们,我有:

petrux@MYMACHINE:~$ dropbox 
  File "/usr/bin/dropbox", line 232
    except OSError, e:
                  ^
SyntaxError: invalid syntax

petrux@orion:~$ software-center
  File "/usr/bin/software-center", line 140
    print time.time()
             ^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

编辑:我刚刚注意到,此外,没有音频输出了。

software-center dropbox python3 14.04

2
推荐指数
2
解决办法
2236
查看次数

在 Ubuntu 15.10 上安装 python 3.x

我的机器上已经安装了 python 2.7。我不记得是我安装了它还是内置安装。无论如何,我想使用 python 3.x 安装工作,我想知道我是否需要先卸载 2.7 版本。系统中是否有依赖此版本的组件?

谢谢。

python apt python3

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

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