Requests module works in Console but not Script - all other modules work normally

≯℡__Kan透↙ 提交于 2020-01-16 00:46:49

问题


I'm getting a very strange error w/ the requests library. When I run:

>>> import requests

in the console it works fine, but when I run the script:

import requests
print('done')

I get an error that it can't find a related module, utils (believe its email.utils)

ImportError: No module named utils

All other modules work load normally. Also, it's just in pycharm where the error occurs - things work fine in sublime text. Any thoughts?


回答1:


You're probably using a different version of python to run the script than you're using for the console. Look at the top of the script. If there's a #/path/to/python, that's the python that will be used when you run the script. You can force it to use the same python as your console by doing python script.py, assuming python is what you normally run to open a console.



来源:https://stackoverflow.com/questions/25150355/requests-module-works-in-console-but-not-script-all-other-modules-work-normall

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!