Python虚拟环境遇到的小问题(pip)

问题

最近想接触下Pyside6做窗口化的程序,然后就在WSL2搭建环境。第一步安装包的时候就卡住了。原因是虽然我的Python在虚拟环境.venv中,但是该环境没有pip。在命令行直接which pip,显示的是系统全局的pip。

解决

多方查询,似乎没有一个很好的解决方案。目前主流的做法是,下载一个自动化pip安装代码curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py,然后在需要安装pip环境激活条件下,运行该文件:python get-pip.py。弄好以后,就可以正常pip install xxx 或者通过可视化插件安装package了。

后续问题与解决方案

由于是在WSL2下运行,系统本身没有图形界面,运行pyside6程序报错:

qt.qpa.plugin: From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load the Qt xcb platform plugin.
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: minimalegl, offscreen, eglfs, wayland, vnc, xcb, wayland-egl, linuxfb, vkkhrdisplay, minimal.

解决方案则是安装libxcb-cursor0,并使用Mobaxterm等支持图形界面渲染的终端运行代码
sudo apt-get install libxcb-cursor0

posted @ 2024-03-28 10:07  GeoAi  阅读(32)  评论(0编辑  收藏  举报