I have
#!/usr/bin/python3
import psycopg2
in my first couple lines of the code. However, it shows that
ImportError: No module named psycopg2
even after I install psycopg2
Below is the detail errors from the ternimal.
432p1:/vagrant> pip3 install psycopg2
Collecting psycopg2
Downloading psycopg2-2.7.3.1-cp35-cp35m-manylinux1_x86_64.whl (2.6MB)
100% |████████████████████████████████| 2.6MB 526kB/s
Installing collected packages: psycopg2
Successfully installed psycopg2-2.6.1
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
432p1:/vagrant> ./test-example.py pys.py
Traceback (most recent call last):
File "./test-example.py", line 2, in <module>
import psycopg2
ImportError: No module named psycopg2
432p1:/vagrant> ./clean-example.py
Traceback (most recent call last):
File "./clean-example.py", line 2, in <module>
import psycopg2
ImportError: No module named psycopg2
432p1:/vagrant>
In addition i tried to run import in my python console and there is no error, however,when i run the test it has error
432p1:/vagrant> python3
Python 3.5.2 (default, Aug 18 2017, 17:48:00)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
>>> ./test-example.py pys.py
File "<stdin>", line 1
./test-example.py pys.py
^
SyntaxError: invalid syntax
>>>
Thanks