How to install Python package / libraries without Admin rights

Zeeshan Ali
2 min readJun 12, 2020

--

Recently I faced an issue where I wanted to install a particular python library, but I did not have Admin access to install packages. The error occurred because pip was unable to create new directory for the package because of lack of privileges, it was giving Access is denied message.

Access is denied

One solution for this is to use executable method in sys package which will return the absolute path of the executable binary for Python against which we can run commands. We add ! (exclamation operator) in front for running it like a shell command from inside notebook, IDE or console.

import sys; !{sys.executable} -m pip install <library_name>

Below code shows installation of kivy package.

import sys!{sys.executable} -m pip install kivy

This can be useful when you have to install python packages when your company or school has given limited privileges. I was documenting it for myself but then wrote an article as it might help someone.

Best of luck in your coding journey !

References:

https://docs.python.org/3.4/library/sys.html#sys.executable

--

--

Zeeshan Ali
Zeeshan Ali

No responses yet