Reputation: 6891
I encountered a bug-like feature of setup.py where I am getting the Permission denied error regardless where I want to install the package without root privilege.
I have a toy python package with a few tiny files, and there is no problem of building it. There is nothing special in the setup.py file. I will list one or two of them.
setup (
name='pmsi',
entry_points={ 'console_scripts': [ 'pmsi = pmsi.pmsi:main', ] },
)
sudo python3 setup.py install
Gave me no problem at all. I need to install this package to a particular place and have tried --user, --home, --prefix options; all gave me the same error message at the egg_info step.
python3 setup.py install --user
running install
running bdist_egg
running egg_info
error: [Errno 13] Permission denied
It appears that the install process always tries to copy the egg_info to some system place where I don't have permission to write. I am not an expert on setup.py, there must be some default rule that I can overwrite either on the command line or setup.py. Or should I always install to system place as root (that seems to be a bad choice, what if you want to test before a system install).
Upvotes: 7
Views: 12780
Reputation: 6891
The reason for this particular difficulty is because I run sudo before in the package directory and it created some directories owned by root. Afterwards, I run as a regular user and got permission issues. The fix is ownership change.
cd ~/lib/python3.8/site-packages
sudo chown -R myuid:mygroup *
After the above action, the problem was resolved. The actual python lib dir may be different for different situation.
Upvotes: 9