0

I'm trying to use python requests module. It works correctly on root account, however when i switch to non-root account i get following error message:

AttributeError: 'module' object has no attribute 'get

which is happening while calling requests.get() function.

I did some testing and noticed something is wrong with imported moduile. Pleae take a look at screenshots - one from regular user account, second from root.

Picture from non-root account (works)

Picture from root account

I tried to delete requests module using pip, even manually.. nothing helped.

Any tips?

It's not same question as resolved already (to MOD), i dont have any subfiles or anything named "requests".

Mark
  • 29
  • 3
  • 1
    Your non-root path is almost certainly loading a different `requests` module. See the duplicate. – Martijn Pieters Oct 11 '17 at 07:29
  • Check the `requests.__path__` value. If that is the local module, always use `from __future__ import absolute_import` (and read about new py3 imports). – Sergey Vasilyev Oct 11 '17 at 07:31
  • Hm no... same path on both. I dont have any sub module or file named requests in python project. It's not even project, just simple console for tests. /usr/local/lib/python2.7/dist-packages/requests. I assume that pip packages installed by root should be visible to all users, correct? Maybe permissions error? – Mark Oct 11 '17 at 07:32
  • 1
    `import requests`, then `print(requests.__file__)` gives you the same path in both instances? – Martijn Pieters Oct 11 '17 at 07:40
  • 2
    Solved. The server is security hardened. It has default umask which permits only the owner and group to read files. I had to apply correct chmods to /usr/local/lib/python2.7/dist-packages/ so all users could read the packages. Thanks for help. – Mark Oct 11 '17 at 07:40
  • Hi Martin, yes. Turned out to be permissions. Thanks for answering. Though it's weird that python doesn't output anything like permission denied. – Mark Oct 11 '17 at 07:41
  • Please unmark this question as a duplicate, as the root cause of it has nothing to do with the linked question accepted answer. – BoboDarph Oct 11 '17 at 07:49

0 Answers0