Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 within the company, where different users have different rights on their specific machines. The problem occurred when another user logged into my machine (I'm having administrator rights there) and tried to use the tool. He was unable to run it, because specific modules could not be imported because of his status as a "non-admin".

The error message is simply "No module named XY". When we looked into the file system, we found that we were not able to look into the folder where the module had been installed, simply because the access was denied by the system. We also got this error message when trying to run pip from the cmd; it prints "Access denied" and won't do anything.

How is it possible, that some modules can be accessed by anyone, while others can't? And how can I get around this problem?

Specifically, I'm talking about sqlalchemy and pyodbc.

Thanks a lot in advance.

EDIT 1: Oh, and we're talking about Windows here, not Linux...

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.

like image 891
s6hebern Avatar asked Nov 17 '25 20:11

s6hebern


1 Answers

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!

like image 135
s6hebern Avatar answered Nov 19 '25 10:11

s6hebern



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!