pycharm连接WSL(Ubuntu)

WSL(Ubuntu)内置python (我的版本是3.10.12),所以不需要部署python了,但如果要调用ollama库,还需要做一些准备。

安装pip工具

sudo apt install python3-pip

Package python3-pip is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'python3-pip' has no installation candidate

如果报了这个错误,通常是因为本地软件包索引未更新,导致系统无法找到最新的包信息。执行以下命令刷新索引:

sudo apt update

更新完成后,再次尝试安装 python3-pip。

安装完毕验证pip

pip -V
pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)

安装ollama、streamlit库

pip install ollama streamlit
// 如果上面的命令因网络超时导致安装失败,就用国内镜像源(如清华、阿里)
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple ollama streamlit
 .
 .
 .
Successfully installed altair-5.5.0 annotated-types-0.7.0 anyio-4.10.0 blinker-1.9.0 cachetools-6.1.0 charset_normalizer-3.4.3 exceptiongroup-1.3.0 gitdb-4.0.12 gitpython-3.1.45 h11-0.16.0 httpcore-1.0.9 httpx-0.28.1 narwhals-2.1.2 numpy-2.2.6 ollama-0.5.3 packaging-25.0 pandas-2.3.1 pillow-11.3.0 protobuf-6.32.0 pyarrow-21.0.0 pydantic-2.11.7 pydantic-core-2.33.2 pydeck-0.9.1 python-dateutil-2.9.0.post0 requests-2.32.5 smmap-5.0.2 sniffio-1.3.1 streamlit-1.48.1 tenacity-9.1.2 toml-0.10.2 tornado-6.5.2 typing-extensions-4.14.1 typing-inspection-0.4.1 tzdata-2025.2 watchdog-6.0.0

出现 Successfully 就是安装成功了

在home/用户,新建放置py_code的目录,准备使用pycharm连接WSL(Ubuntu)

打开pycharm,选中remote development中的 WSL,新建项目

自动选择之前安装好的 Ubuntu-22.04,点击next

选择IDE 版本(跟你本地pycharm相同版本即可)和工程路径(之前建好的放置py_code的目录)

点击 start ide and connect,等待。网好会很快~

启动成功后,测试工程能否正常运行,能否调用ollama

正常输入ollama list和streamlit version,本地pycharm连接WSL(Ubuntu)调用ollama成功

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值