You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用asdf安装Python后创建virtualenv虚拟环境报错求助

解决asdf管理Python时virtualenv报错问题

报错信息

No preset version installed for command virtualenv
Please install a version by running one of the following:

asdf install python 3.10.7

or add one of the following versions in your config file at
python 3.10.4
python 3.9.12

解决步骤

  • 安装指定Python版本
    先按提示安装对应Python版本,比如3.10.7:

    asdf install python 3.10.7
    
  • 设置Python版本生效
    选择全局或局部生效:

    • 全局生效(系统所有项目使用该版本):
      asdf global python 3.10.7
      
    • 局部生效(仅当前项目目录使用):
      asdf local python 3.10.7
      
  • 安装virtualenv到当前Python环境
    用对应版本的pip安装virtualenv,确保asdf能识别到该命令:

    pip install virtualenv
    
  • 更新asdf命令索引
    安装完成后执行reshim,让asdf识别新安装的virtualenv命令:

    asdf reshim python
    
  • 重新创建虚拟环境
    现在执行原命令即可正常创建:

    virtualenv whatsapp-bot
    

备选方案(不固定版本)

如果不想全局/局部固定Python版本,可在项目目录的.tool-versions文件中添加指定版本,比如:

python 3.10.7

保存后执行asdf reshim python,再按上述步骤安装virtualenv即可。

内容的提问来源于stack exchange,提问作者Sverre Jørn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 19:45:34