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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)