hughperkins / pytorch

Python wrappers for torch and lua

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

permission denied: python setup.py install

moon6pence opened this issue · comments

I have python 2.7 which installed by default in Ubuntu 14.04
And torch is installed in my home directory.

When I run the script build.sh, there's permission denied error like below:

running install
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-18167.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /usr/local/lib/python2.7/dist-packages/

This is obvious because python setup.py install tend to install below /usr/local/lib/python2.7
sudo ./build.sh also fails because it cannot find the torch when I use sudo.

My solution was update the last line of build.sh like this:

python setup.py install --user || exit 1

pytorch package is installed below my home directory and it works well.

However, how do you install this package in general situation?

What I do personally is like:

sudo apt-get install python-virtualenv python2.7-dev
virtualenv -p python2.7 ~/env27
source ~/env27/bin/activate
pip install -U pip
pip install -U wheel
pip install -U setuptools
pip install -U numpy
pip install -U docopt
source ~/torch/install/bin/torch-activate
git clone https://github.com/hughperkins/pytorch ~/pytorch
cd ~/pytorch
./build.sh

To what extent does this meet your requirements for your own system?

thanks moon6pence for the solution it worked for me

Addressed in 05b09e3 :

  • if in virtualenv , uses existing installation method
  • otherwise adds --user

Thank you Kyunghun and Sounak; I confess I didnt know about --user before :-)

thanks moon6pence for the solution it worked for me

python setup.py install --user || exit 1
worked for me

If you're on windows just run cmd or power shell as administrator

When using virtualenv(no matter whether we have ||exit 1):
$ source ~/py36/bin/activate
$ python setup.py install --user [|| exit 1]
...
...
running install_egg_info
running egg_info
error: [Errno 13] Permission denied
$ which python
/home/cmal/py36/bin/python
$ python --version
Python 3.6.12
$ which pip
/home/cmal/py36/bin/pip
$ pip -V
pip 20.0.2 from /home/cmal/py36/lib/python3.6/site-packages/pip (python 3.6)