Sublime Forum

Sublime text 3 plugin use requests module

#1

Hey guys,

I’m having a problem with using python module requests, in my sublime plugin, for some reason when I import requests it founds module but there are no methods.

   requests.get(
AttributeError: 'module' object has no attribute 'get'

any ideas?

0 Likes

#2

Did added dependencies.json file? It contains the required libraries.
This should be the format of file

{
   "*": {
      "*": [
         "requests",
      ]
   }
}
0 Likes

#3

Yes, same as this one

0 Likes

#4

Is there a file/directory/module having the same name requests in your plugin so Python imported the wrong one?

0 Likes

#5

I am getting this same issue when using python3.8 rather than 3.3
(using a .python-version file 3.8)
Changing it back to 3.3 fixes the issue

As 3.3, then, make the change to 3.8:

(This true in a very minimum setup) - a project folder with:
.python-version as 3.8
dependencies.json as


{
  "*": {
    "*": [
      "requests"
    ]
  }
}

test.py as

import sublime
import sublime_plugin

import requests


class TestCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        print(requests.get('http://example.com/'))

Hopefully that helps debugging. Any thoughts?

0 Likes

#6

Package Control doesn’t support dependencies/libraries for plugins running on python 3.8 plugin host, yet.

The only current option is to vendor any kind of 3rd-party library in your plugin.

0 Likes

#7

Ah, understood, thank you!
In the future, it might be nice to have a note in the documentation, or something similar, so I submitted a request to, I believe, the proper place (issue on github)
Thanks again for your help!

0 Likes