Forums

installing xgboost on PythonAnywhere

I am trying to install xgboost

git clone --recursive https://github.com/dmlc/xgboost
cd xgboost
make -j4
cd /home/lav/xgboost/python-package 
python setup.py install

and geting the following error :

error: can't create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory:
    [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/test-easy-install-14889.write-test'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
    /usr/local/lib/python2.7/dist-packages/
Perhaps your account does not have write access to this directory?

i have payed account . how to make xgboost work on PythonAnywhere?

[edited by admin: formatting]

hi- you don't have write access to /usr/local/lib/python2.7/dist-packages/.

You should use the --prefix option when going through the ./configure and ./make steps to specify a directory you can write to. (eg: /home/lav/mydirectory)

@conrad sory ,i dont get it . Where i should usr --prefix . when i clone git ?

It seems the easiest would be to change the last step to be:

cd python-package
python setup.py develop --user

See this

@conrad Thanks a lot i made this step

cd python-package
python setup.py develop --user

and all installed

Adding xgboost 0.6 to easy-install.pth file
Installed /home/lav/xgboost/python-package
Processing dependencies for xgboost==0.6
Searching for scipy==0.18.0
Best match: scipy 0.18.0
Adding scipy 0.18.0 to easy-install.pth file
Using /usr/local/lib/python2.7/dist-packages
Searching for numpy==1.11.1
Best match: numpy 1.11.1
Adding numpy 1.11.1 to easy-install.pth file
Using /usr/local/lib/python2.7/dist-packages
Finished processing dependencies for xgboost==0.6

but xgboost doesn't work anyway . Then i import xgboost i get no erros . but when i am trying methods from xgboost nothing work

import xgboost as xgb 
booster = xgb.Booster()

AttributeError: module 'xgboost' has no attribute 'Booster'

i think i nedd to compile something after -python setup.py develop --user i had tried everything i can but i dont know how to make xgboost work

[edited by admin for formatting]

I just did a quick test and it works for me. Could something be clashing with the installed xgboost package? Do you have a python file called xgboost.py, or maybe a directory named "xgboost" that is clashing with the one you actually want to import?

When I ran "pip install xgboost", it seems to go fine (please see the msg below). But when I ran my python file, I am getting the following error: No module named 'xgboost' Any help will be greatly appreciated.

=========================================
21:23 ~ $ pip install xgboost
Requirement already satisfied (use --upgrade to upgrade): xgboost in ./xgboost/python-package
Requirement already satisfied (use --upgrade to upgrade): numpy in /usr/local/lib/python2.7/dist-packages (from xgboost)
Requirement already satisfied (use --upgrade to upgrade): scipy in /usr/local/lib/python2.7/dist-packages (from xgboost)
22:42 ~ $ python 
Python 2.7.6 (default, Oct 26 2016, 20:30:19) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

[edit by admin: formatting]

How are you running your Python file? Is it from the editor, or by typing "python2.7 myscript.py" in a bash console?

14:38 ~ $ mkvirtualenv flaskk --python=3.10 created virtual environment CPython3.10.5.final.0-64 in 9814ms creator CPython3Posix(dest=/home/junaid1990/.virtualenvs/flaskk, clear=False, no_vcs_ignore=Fal se, global=False) seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_d ata_dir=/home/junaid1990/.local/share/virtualenv) added seed packages: pip==22.1.2, setuptools==62.6.0, wheel==0.37.1 activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,Pyt honActivator virtualenvwrapper.user_scripts creating /home/junaid1990/.virtualenvs/flaskk/bin/predeactivate virtualenvwrapper.user_scripts creating /home/junaid1990/.virtualenvs/flaskk/bin/postdeactivate virtualenvwrapper.user_scripts creating /home/junaid1990/.virtualenvs/flaskk/bin/preactivate virtualenvwrapper.user_scripts creating /home/junaid1990/.virtualenvs/flaskk/bin/postactivate virtualenvwrapper.user_scripts creating /home/junaid1990/.virtualenvs/flaskk/bin/get_env_details (flaskk) 14:39 ~ $ pip install xgboost Looking in links: /usr/share/pip-wheels Collecting xgboost Downloading xgboost-1.7.5-py3-none-manylinux2014_x86_64.whl (200.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 200.3/200.3 MB 992.5 kB/s eta 0:00:00 ERROR: Could not install packages due to an OSError: [Errno 122] Disk quota exceeded (flaskk) 14:39 ~ $

16:07 ~ $ mkvirtualenv myvirtualenv --python=/usr/bin/python3.7 created virtual environment CPython3.7.13.final.0-64 in 400312ms creator CPython3Posix(dest=/home/junaid1990/.virtualenvs/myvirtualenv, clear=False, no_vcs_igno re=False, global=False) seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_d ata_dir=/home/junaid1990/.local/share/virtualenv) added seed packages: pip==22.1.2, setuptools==62.6.0, wheel==0.37.1 activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,Pyt honActivator virtualenvwrapper.user_scripts creating /home/junaid1990/.virtualenvs/myvirtualenv/bin/predeactiv ate virtualenvwrapper.user_scripts creating /home/junaid1990/.virtualenvs/myvirtualenv/bin/postdeacti vate virtualenvwrapper.user_scripts creating /home/junaid1990/.virtualenvs/myvirtualenv/bin/preactivat e virtualenvwrapper.user_scripts creating /home/junaid1990/.virtualenvs/myvirtualenv/bin/postactiva te virtualenvwrapper.user_scripts creating /home/junaid1990/.virtualenvs/myvirtualenv/bin/get_env_de tails (myvirtualenv) 16:15 ~ $ which pip /home/junaid1990/.virtualenvs/myvirtualenv/bin/pip (myvirtualenv) 16:19 ~ $ pip install xgboost Looking in links: /usr/share/pip-wheels Collecting xgboost Downloading xgboost-1.6.2-py3-none-manylinux2014_x86_64.whl (255.9 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 255.9/255.9 MB 686.6 kB/s eta 0:00:00 ERROR: Could not install packages due to an OSError: [Errno 122] Disk quota exceeded (myvirtualenv) 16:21 ~ $

It looks like you would need a paid account in order to install that; it's trying to use up more than the space available in a free account.