Skip to content Skip to sidebar Skip to footer

Why Can I Import Certain Modules In Python Only With Administrator Rights?

I'm struggling with some strange issues in Python 2.7. I wrote a very long tool where I import different modules, which I had to install first using pip. The tool is to be shared w

Solution 1:

Got it...

Following the advice of Nabeel Ahmed, I first uninstalled the packages which caused the issues from my admin account. Then I changed the script to

pip install --user {module_name}

and voila... it works for all users now.

Thanks a lot for you help, guys!

Solution 2:

You should either use virtualenv as stated before or set the proper permissions to the site-packages folder. I should be in C:\Python27\Lib.

Solution 3:

One simply solution is set permissions for site-package directory (where the packages gt installed) as per usable by all i.e. read and execute permission for all on the directory:

sudo chmod -Rv ugo+rX /usr/lib/python2.7/site-packages/

Also for the lib64 packages - the path to site-packages may vary for various Linux distros.


Edit 1: For windows look into this 'File and Folder Permissions' for setting Read & Execute permissions for all, for a file or folder (i.e. site-packges)

The path 'd be - C:\Python27\Lib\site-packages


Edit 2: in apropos of:

EDIT 2: Due to company policy it is not possible to set administrator permissions to all users. I tried, as suggested, but it didn't work and I learned that it's not possible within the company.

if so, simply install sqlalchemy (or any other package) for specific user using pip:

pip install --user {module_name} 

Source: Per user site-packages directory.

Post a Comment for "Why Can I Import Certain Modules In Python Only With Administrator Rights?"