python 2.7 windows ImportError:没有名为OpenSSL的模块

时间:2016-04-18 06:43:35

标签: python-2.7 module openssl

我尝试使用python 2.7和this is我的源代码在windows上制作https服务器。当我运行它时我得到了这个错误。

Traceback (most recent call last):
  File "httpserver.py", line 38, in <module>
    from OpenSSL import SSL
ImportError: No module named OpenSSL

我是否需要先安装该模块,还是默认安装在我的系统上? 或者可能有什么问题?

1 个答案:

答案 0 :(得分:1)

我认为您必须安装OpenSSL模块。

Python按顺序使用下面的搜索路径来查找您要导入的模块:

  1. 程序的主目录

  2. 环境变量PYTHONPATH中的指令

  3. 标准图书馆指令

  4. 任何.pth文件的内容

  5. 我猜python程序在上面第1项和第2项中找不到任何内容。

    因此,请尝试使用以下内容检查标准库目录:

    import sys
    print sys.path
    

    它将返回标准库目录的路径。只需检查这些目录,如果您没有看到OpenSSL,那么是的,您必须先安装模块。