python-3.x 库如何工作?尝试安装mouseinfo

oknrviil  于 2023-03-09  发布在  Python
关注(0)|答案(3)|浏览(180)

我正在尝试创建一个使用'mouseinfo'模块的AutoKey(Linux)脚本。

pip3 install mouseinfo
I ran this line while I use in
~/.config/autokey/data/My_Scripts

但当我试着

import mouseinfo

在我的python脚本中,它似乎找不到它。
我真的不知道python库是如何组织的,以及如何正确地使用它们。

python3 -m site
sys.path = [
'/home/myusr/.local/lib/python3.6/site-packages',
'/usr/lib/python36.zip',
'/usr/lib/python3.6',
'/usr/lib/python3.6/lib-dynload',
'/usr/local/lib/python3.6/dist-packages',
'/usr/lib/python3/dist-packages',
]
USER_BASE: '/home/myusr/.local' (exists)
USER_SITE: '/home/myusr/.local/lib/python3.6/site-packages' (exists)
ENABLE_USER_SITE: True

及之后

cd /home/myusr/.local/lib/python3.6/site-packages
ls

我得到了一个软件包列表,可以看到mouseinfo。下一步是什么?

which python3
/usr/bin/python3

另一个尝试:

sudo apt-get install python3-venv
python3 -m venv env
source env/bin/activate
Successfully installed mouseinfo-0.1.3
pip3 install mouseinfo

Screenshot
正如您所看到的,模块已安装(我认为)。
还是什么都没有。
我在Reolith Linux(Ubuntu最新版本)上,使用Zsh和Vim(当然还有Python 3),如果有必要的话。
接下来呢?
编辑:我也试着安装Xlib,同样的情况,不能导入它。很明显,由于我对Python的无知,我做错了什么,但不知道是什么。
编辑2:为Vim安装了virtualenv插件,但是:VirtualEnvList返回“不是编辑器命令”。
编辑3:激活venv,并且:

source env/bin/activate
~/.config/autokey/data/My_Scripts
pip install mouseinfo
Requirement already satisfied: mouseinfo in ./env/lib/python3.6/site-packages (0.1.3)
Requirement already satisfied: python3-Xlib; platform_system == "Linux" and python_version >= "3.0" in ./env/lib/python3.6/site-packages (from mouseinfo) (0.15)
Requirement already satisfied: Pillow>=4.0.0; python_version == "3.6" in ./env/lib/python3.6/site-packages (from mouseinfo) (7.1.1)
Requirement already satisfied: pyperclip in ./env/lib/python3.6/site-packages (from mouseinfo) (1.8.0)

pip3 install mouseinfo
Requirement already satisfied: mouseinfo in ./env/lib/python3.6/site-packages (0.1.3)
Requirement already satisfied: pyperclip in ./env/lib/python3.6/site-packages (from mouseinfo) (1.8.0)
Requirement already satisfied: Pillow>=4.0.0; python_version == "3.6" in ./env/lib/python3.6/site-packages (from mouseinfo) (7.1.1)
Requirement already satisfied: python3-Xlib; platform_system == "Linux" and python_version >= "3.0" in ./env/lib/python3.6/site-packages (from mouseinfo) (0.15)

在终端运行python3后,似乎可以导入模块。问题可能是Vim。有什么想法吗?

q5lcpyga

q5lcpyga1#

由于默认的pip3python3位于不同的位置,因此可以尝试安装该包,方法是首先调用所需的python安装并调用pip

python3 -m pip install mouseinfo
wkftcu5l

wkftcu5l2#

我决定给予Vim而使用Visual Studio代码,并使用pyautogui的位置来代替。

jjhzyzn0

jjhzyzn03#

1:pip 3安装鼠标信息2:sudo apt-get安装脚本

相关问题