简体   繁体   中英

Python import error with Sublime Text 2 with same PYTHONPATH and Python version as terminal

I just installed gdata with pipinstall

while I can import when starting python from the command line:

import gdata.docs.service

I get an

ImportError: No module named docs.service

when I do it with the sublime python build. I realize that on Python.sublime-build I can specify the python version and the PYTHOPATH.

I checkt both and made sure to have both the same as on the command line. I also checked that the folder from where I start the python console does not include gdata. What am I missing?

my PYTHONPATH check:

import os
try:
    user_paths = os.environ['PYTHONPATH'].split(os.pathsep)
except KeyError:
   user_paths = []

print user_paths

and the Python version check:

import sys
print (sys.version)

I also checked that $which python is the same path as the "cmd" value in the sublime build config file.

I finally find the answer. The named the file gdata.py and this is why the import gdata.docs.service was resolved with the file itself and could obviously not find "docs" in it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM