Friday, February 18, 2022

[SOLVED] Cannot install xgboost library on python virtual enviroment

Issue

I am using PyCharm and Python 3.6 for 32-bit Windows.

I try to install the xgboost library for python by going on Pycharm to File -> Default Settings and choosing a virtual ennviroment interpreter used by all my projects (C:\Users\User\PycharmProjects\Project_name\venv\Scripts\python.exe) instead of the local(C:\Users\User\AppData\Local\Programs\Python\Python36-32\python.exe).

However, I am getting the following error:

Collecting xgboost
  Using cached https://files.pythonhosted.org/packages/83/3a/8570f4e8e19acd3a5a75abc920964182a4b64db2ee0f041fb77b48447c6b/xgboost-0.72.tar.gz

No files/directories in C:\Users\User\AppData\Local\Temp\pycharm-packaging\xgboost\pip-egg-info (from PKG-INFO)

I am getting the same exactly error when I enter at the command prompt window

C:\Users\User>PycharmProjects\Sentdex_ML\venv\Scripts\pip install xgboost

I have also read a relevant StackOverflow post (How to install xgboost package in python (windows platform)?) and followed the (most upvoted) answer of @brettlyman.

Specifically, I donwloaded xgboost-0.72-cp36-cp36m-win32.whl and I entered at the command prompt

pip install xgboost-0.72-cp36-cp36m-win32.whl

However, in this way I successfuly installed xgboost on my local interpreter and not on my virtual enviroment interpreter which I am actually using. (Therefore @Moses' answer regarding Windows was not useful either - How do I install a .whl file in a PyCharm virtualenv?)

How can I install xgboost on my virtual enviroment?

When I enter pip3 install xgboost at the command promt window then I am getting the following:

Requirement already satisfied: xgboost in c:\users\User\appdata\local\programs\python\python36-32\lib\site-packages
Requirement already satisfied: numpy in c:\users\User\appdata\local\programs\python\python36-32\lib\site-packages (from xgboost)
Requirement already satisfied: scipy in c:\users\User\appdata\local\programs\python\python36-32\lib\site-packages (from xgboost)

Therefore, by entering this it is again verified that xgboost is installed at my local interpreter (but not on my virtual enviroment).


Solution

Ok I figured out how to do this and finally xgboost is properly installed on my virtual enviroment.

Specifically I did the following:

  1. I downloaded xgboost .whl file from this url
  2. I opened the command prompt (cmd)
  3. I activated the specific virtual enviroment by entering C:\Users\User\PycharmProjects\Project_name\venv\Scripts\activate at the cmd
  4. then I entered/went at the cmd to the folder directory where the .whl file is stored
  5. finally I entered pip install xgboost-0.72-cp36-cp36m-win32.whl in this directory at the cmd

Thanks to @brettyman and @Moses because a combination of their answers at How to install xgboost package in python (windows platform)? and at How do I install a .whl file in a PyCharm virtualenv? respectively solved my problem.



Answered By - Outcast
Answer Checked By - Robin (WPSolving Admin)