python installation can't find psycopg2 ImportError

自作多情 提交于 2019-12-02 07:13:45

问题


I'm calling on psycopg2 with

import psycopg2

I get the std error

ImportError: No module named psycopg2

I installed my copy with macports, so I'm curious why it wouldn't work because all of the dependencies should be downloaded as well. I don't have any experience with Postgresql, nor this module, so I don't know what could be going wrong. Fact is, another project I'm trying to get built calls upon it, so if I could avoid using this I would. :)

I'm sure that postgresql is installed, but that has little to do with the fact that my installation can't find psycopg2. Any suggestinos would be appreciated.

$ which python

reveals

/Library/Frameworks/Python.framework/Versions/Current/bin/python

and

$ python --version

reveals

Python 2.7.3 -- EPD_free 7.3-2 (32-bit)

I don't necessarily want the version of EPD_free, but I had to install it for (somewhat) unrelated reasons.


回答1:


MacPorts installs its own version of Python alongside Apple's version. You can manage the active version of Python (the one that gets run when you type in python at the command line or by /usr/bin/env) by using the port select command. See this question.



来源:https://stackoverflow.com/questions/14409944/python-installation-cant-find-psycopg2-importerror

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