[Seek Help] 【已解决】双击desktop文件exec没有运行当前用户下的python环境
Tofloor
poster avatar
风吹过的绿洲
deepin
2022-08-10 06:02
Author

截图_选择区域_20220809215327.png

我怀疑默认以root用户运行,而root用户下的python环境和自己用户下的python环境不一样。


![image.png](https://storage.deepin.org/thread/202208092159216212_image.png)
root@jay-PC:~# python3 -m pip install vosk srt -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting vosk
/usr/share/python-wheels/urllib3-1.24.1-py2.py3-none-any.whl/urllib3/connectionpool.py:849: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  Could not find a version that satisfies the requirement vosk (from versions: )
No matching distribution found for vosk
root@jay-PC:~# 

也尝试过,root下安装,安装失败。

而用户环境下早就装好了。
截图_选择区域_20220809215908.png

在用户环境下,命令行打开软件没问题,软件能正常加载python依赖包。

root环境下,因为包安装不了,直接双击desktop或者命令下都不行。

所以: 怎么让desktop以用户环境运行呢?

Reply Favorite View the author
All Replies
1 / 2
To page
风吹过的绿洲
deepin
2022-08-10 06:05
#1

image.png

目的是为了解决这个问题。双击desktop是上面这样子,安装也报错。

目前用户环境命令行运行,没有问题,可以加载语音包。

Reply View the author
寂静的羽夏
deepin
2022-08-10 06:10
#2

你可以在 root 权限下进行安装,也就是说 sudo su完后执行安装命令。

但我得吐槽你一句,为啥要在 root 权限下进行视频剪辑工作呢?视频剪辑不涉及修改系统配置等具有对系统具有危险性的操作,就没必要在 root 下搞这东西。

Reply View the author
Ziggy
deepin
2022-08-10 06:34
#3

root运行dde会被检测到且不被执行大部分程序

Reply View the author
神末shenmo
Moderator
Spark-App
2022-08-10 06:36
#4

exec后面不会root的

是那个AppRun脚本里面有鬼

你去看看

Reply View the author
风吹过的绿洲
deepin
2022-08-10 06:39
#5
寂静的羽夏

你可以在 root 权限下进行安装,也就是说 sudo su完后执行安装命令。

但我得吐槽你一句,为啥要在 root 权限下进行视频剪辑工作呢?视频剪辑不涉及修改系统配置等具有对系统具有危险性的操作,就没必要在 root 下搞这东西。

我当然不想在root下操作啊!双击desktop文件,安装那个那个依赖,一直失败,然而我本地用户已经手动安装上了。才怀疑双击用的不是当前用户。

Reply View the author
风吹过的绿洲
deepin
2022-08-10 06:44
#6
Ziggy

root运行dde会被检测到且不被执行大部分程序

我是怀疑在root用户下运行。关键是双击不行。。。。用户下命令行打开,可以。

Reply View the author
风吹过的绿洲
deepin
2022-08-10 06:45
#7
神末shenmo

exec后面不会root的

是那个AppRun脚本里面有鬼

你去看看

我在用户目录下,命令行打开appRun没问题呀。所以我就不知道哪里的鬼了

Reply View the author
风吹过的绿洲
deepin
2022-08-10 06:45
#8
It has been deleted!
安洛
deepin
2022-08-10 06:53
#9

desktop文件是以用户权限运行的。

你是不是没有全局设置把pip包的路径添加到PATH环境变量里面?

Reply View the author
xiao80
deepin
2022-08-10 13:10
#10
It has been deleted!
xiao80
deepin
2022-08-10 13:24
#11

可以肯定的是,.desktop 不会默认以 root 运行。

你的系统里现在有几个 python 环境呢?/usr/bin/python 或 /usr/bin/python3 指向的又是哪个环境呢?

你说命令下运行正常,.desktop 运行不正常,所以你怀疑 .desktop 默认以 root 运行,那你有没有想过也许是 .desktop 运行用到的 python 环境,和你命令行下的 python 环境不一致呢(也许是在 .bashrc 或 .zshrc 里配置了特定的 python 环境?)?

Reply View the author
hotime
deepin
2022-08-10 21:03
#12

https://alphacephei.com/vosk/install

vosk安装要求:

Make sure you have up-to-date pip and python3 versions:

  • Python version: 3.5-3.9
  • pip version: 20.3 and newer.

Deepin的仓库中python3-pip的版本是18.1-5,所以你需要临时添加Debian-Bullseye的源deb http://ftp.cn.debian.org/debian bullseye main,然后安装20.3版本的python3-pip。(安装完再把Debian源屏蔽了)

这之后你才能正常安装vosk。

截图_选择区域_20220810130419.png

Reply View the author
安洛
deepin
2022-08-10 21:10
#13
hotime

https://alphacephei.com/vosk/install

vosk安装要求:

Make sure you have up-to-date pip and python3 versions:

  • Python version: 3.5-3.9
  • pip version: 20.3 and newer.

Deepin的仓库中python3-pip的版本是18.1-5,所以你需要临时添加Debian-Bullseye的源deb http://ftp.cn.debian.org/debian bullseye main,然后安装20.3版本的python3-pip。(安装完再把Debian源屏蔽了)

这之后你才能正常安装vosk。

截图_选择区域_20220810130419.png

不需要通过添加额外仓库来更新pip。pip自带更新功能:

python -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip
Reply View the author
hotime
deepin
2022-08-10 21:27
#14
安洛

不需要通过添加额外仓库来更新pip。pip自带更新功能:

python -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip

哦哦学到了!另外:python默认是python2,所以得python3吧?

python3 -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip
Reply View the author
风吹过的绿洲
deepin
2022-08-10 23:20
#15
安洛

desktop文件是以用户权限运行的。

你是不是没有全局设置把pip包的路径添加到PATH环境变量里面?

我是用pyenv管理python版本的,global是3.8了

Reply View the author
风吹过的绿洲
deepin
2022-08-11 05:12
#16
xiao80

可以肯定的是,.desktop 不会默认以 root 运行。

你的系统里现在有几个 python 环境呢?/usr/bin/python 或 /usr/bin/python3 指向的又是哪个环境呢?

你说命令下运行正常,.desktop 运行不正常,所以你怀疑 .desktop 默认以 root 运行,那你有没有想过也许是 .desktop 运行用到的 python 环境,和你命令行下的 python 环境不一致呢(也许是在 .bashrc 或 .zshrc 里配置了特定的 python 环境?)?


(anaconda3-2020.11) jay@jay-PC:~$ python -V
Python 3.8.5
(anaconda3-2020.11) jay@jay-PC:~$ /usr/bin/python -V
Python 2.7.16
(anaconda3-2020.11) jay@jay-PC:~$ /usr/bin/python3 -V
Python 3.7.3
(anaconda3-2020.11) jay@jay-PC:~$ 
(anaconda3-2020.11) jay@jay-PC:~$ zsh
╭─jay@jay-PC ~ 
╰─‹anaconda3-2020.11› λ python -V                                                                                                       
Python 3.8.5

我的python环境是这样的,不知道它用的那个环境。不应该用不带路径的这个吗?

但是从日志来看用的是3.7.3这个

Reply View the author
xiao80
deepin
2022-08-11 06:08
#17

https://github.com/KDE/kdenlive/blob/master/data/scripts/speech.py

#!/usr/bin/env python3

#pip3 install vosk
#pip3 install srt

从这个源码看,kdenlive 用到的环境是 python3。

根据你说的情况和日志,我的判断是:

.desktop 运行时 python3 环境指向了 /usr/bin/python3 (3.7.3) 这个版本,而在命令行下运行时,由于加载了.zshrc/.bashrc 的一些配置,导致 python3 指向了 3.8.5 的环境(你可以在命令行下看下 which python3 看下具体指向了哪里)。

如果你需要多环境并存的话,建议在 python3.7.3 这个系统默认环境下安装好 pip ,再手动安装相应的包或者等 kdenlive 自己安装。

Reply View the author
xiao80
deepin
2022-08-11 06:45
#18

安装 pip3 可以参考 @安洛 说的方法,添加安装源,不过需要注意的是,在普通用户下,你需要用绝对路径 /usr/bin/python3 进行操作。

Reply View the author
风吹过的绿洲
deepin
2022-08-11 07:06
#19
xiao80

https://github.com/KDE/kdenlive/blob/master/data/scripts/speech.py

#!/usr/bin/env python3

#pip3 install vosk
#pip3 install srt

从这个源码看,kdenlive 用到的环境是 python3。

根据你说的情况和日志,我的判断是:

.desktop 运行时 python3 环境指向了 /usr/bin/python3 (3.7.3) 这个版本,而在命令行下运行时,由于加载了.zshrc/.bashrc 的一些配置,导致 python3 指向了 3.8.5 的环境(你可以在命令行下看下 which python3 看下具体指向了哪里)。

如果你需要多环境并存的话,建议在 python3.7.3 这个系统默认环境下安装好 pip ,再手动安装相应的包或者等 kdenlive 自己安装。

是的指向的是3.7.3,然而这个对我其实没啥用,可能是系统自带的,我没有卸载。我使用pyenv管理Python的版本,在.bashrc和.zshrc里面有初始化,pyenv指定的版本。

Reply View the author
风吹过的绿洲
deepin
2022-08-11 07:14
#20
xiao80

安装 pip3 可以参考 @安洛 说的方法,添加安装源,不过需要注意的是,在普通用户下,你需要用绝对路径 /usr/bin/python3 进行操作。

升级pip之后可以了,感谢各位出谋划策!

╭─jay@jay-PC ~/.local/share/omf/themes/lambda/functions ‹master› 
╰─‹anaconda3-2020.11› λ /usr/bin/python3 -m pip install vosk srt -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting vosk
/usr/share/python-wheels/urllib3-1.24.1-py2.py3-none-any.whl/urllib3/connectionpool.py:849: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  Could not find a version that satisfies the requirement vosk (from versions: )
No matching distribution found for vosk
Reply View the author
1 / 2
To page