python脚本导入错误

时间:2017-11-21 12:57:44

标签: python import

我有一个包含这些导入行的python脚本:

import os
import sys
import SA_auth_keys
from tweepy.streaming import StreamListener
from tweepy import OAuthHandler
from tweepy import Stream
from tweepy import API
from tweepy import Cursor
from tweepy.error import RateLimitError, TweepError
from optparse import OptionParser
import ast

尝试运行脚本时出现此错误:

Traceback (most recent call last):
File "2_From_IDs_To_JSON.py", line 23, in <module>
    import SA_auth_keys
ImportError: No module named SA_auth_keys

如何运行脚本?

1 个答案:

答案 0 :(得分:0)

尝试以下两种方法可能会解决您的问题:

  1. exec命令: execfile('SA_auth_keys.py')
  2. 启动Shell进程: os.system('python SA_auth_keys.py')