Python:Pycharm下无法导入安装好的第三方模块?

时间:2023-12-13 20:36:32

Pycharm下无法导入安装好的第三方模块requests?

在cmd下使用pip安装好requests模块后,可以使用import requests,但在Pycharm IDE下无法导入,出现如下错误: 

>>> import requests
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.2\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ImportError: No module named requests

原因:电脑里同时装了Python2.7 和 Python3.5 ,只在Python3.5下安装了requests模块,并没有在Python2.7 下安装。

解决:

  调整Pycharm设置:Settings -->Project:Python -->Project Interpreter 将其改为Python3.5即可。