Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
415 views
in Technique[技术] by (71.8m points)

python - ModuleNotFoundError: No module named 'psycopg2' when running

When I'm trying to run a .py file from the command prompt on Windows 10, I get the error: ModuleNotFoundError: No module named 'psycopg2'. However, it was installed successfully and works from the interpreter. The conn_test.py file contains only the import psycopg2 statement.

C:Users212703751>python -m pip install psycopg2-binary
Collecting psycopg2-binary
  Using cached psycopg2_binary-2.8.6-cp37-cp37m-win_amd64.whl (1.1 MB)
Installing collected packages: psycopg2-binary
Successfully installed psycopg2-binary-2.8.6

C:Users212703751>python
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
>>> exit()

C:Users212703751>conn_test.py
Traceback (most recent call last):
  File "C:Users212703751AppDataLocalProgramsPythonPython37conn_test.py", line 1, in <module>
    import psycopg2
ModuleNotFoundError: No module named 'psycopg2'

I've tried many approaches, none of them worked.

Do you have any idea, how can I solve this? I'm using Windows 10 x64, and Python 3.7.2

question from:https://stackoverflow.com/questions/66054761/modulenotfounderror-no-module-named-psycopg2-when-running

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...