但是模块已经安装在

但是模块已经安装在

本文介绍了导入错误:“没有命名的模块".但是模块已经安装在 dist-packages 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 python2.7 并尝试导入诸如 psycopg2 之类的模块.但是当我尝试导入模块时出现以下错误:

I am using python2.7 and trying to import modules such as psycopg2. But I get the following error when I try to import the module:

import psycopg2
ImportError: No module named psycopg2

当我尝试 pip 安装模块时,它给了我以下消息:

When I try pip to install the module it gives me the following message:

Requirement already satisfied (use --upgrade to upgrade): psycopg2 in /usr/local/lib/python2.7/dist-packages
Cleaning up...

谁能告诉我我做错了什么?

Can anyone please tell me what I am doing wrong?

推荐答案

模块是否安装在你的 PYTHONPATH 中?

Is the module installed in your PYTHONPATH?

您可以验证运行此命令行:

You can verify running this command line:

python -c "import sys; print '/usr/local/lib/python2.7/dist-packages' in sys.path"

这篇关于导入错误:“没有命名的模块".但是模块已经安装在 dist-packages 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 20:48