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

如何卸载从源码安装的Python版XGBoost?pip卸载失败求助

How to Uninstall Source-Installed XGBoost & Reinstall the Latest Version

Hey there, let's sort out this XGBoost uninstall problem you're hitting! Since you installed XGBoost from source code instead of using pip, pip doesn't track that installation—this is exactly why you're seeing the "Cannot uninstall requirement xgboost, not installed" error. Here's a step-by-step fix:

  • Step 1: Locate your XGBoost installation folder
    Open a Python shell and run these lines to find where XGBoost is installed:

    import xgboost
    print(xgboost.__file__)
    

    This will output a path like /usr/local/lib/python3.9/site-packages/xgboost/__init__.py. The folder you need to delete is the parent directory of this file—so in this example, it's /usr/local/lib/python3.9/site-packages/xgboost/.

  • Step 2: Manually delete the XGBoost folder

    • For Linux/macOS, use this terminal command (replace the path with your actual folder location):
      rm -rf /path/to/your/xgboost/folder
      
    • For Windows, you can either navigate to the folder in File Explorer and delete it, or run this Command Prompt command:
      rmdir /s /q C:\path\to\your\xgboost\folder
      
  • Step 3: Verify the uninstall
    Open a new Python shell and try running import xgboost. If you get a ModuleNotFoundError, that means the old installation is gone for good.

  • Step 4: Install the updated XGBoost
    Now you're ready to install the latest version. You can either:

    • Compile it from the updated source code following the same steps you used before, or
    • Use pip to install the latest stable release:
      pip install --upgrade xgboost
      

A quick note: If your original source compilation installed system-level libraries (rare for most Python setups), you can navigate back to the folder where you compiled XGBoost and run make uninstall if the project's Makefile supports it. But for most cases, deleting the site-packages folder is sufficient.

内容的提问来源于stack exchange,提问作者Silburt

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 10:31:50