Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PostgreSQL- import package
i am trying to use postgreSQL package , i had tried the following:
python -m pip install -U pip setuptools
pip install 'psycopg2'
import postgresq2
import postgresql
all what i get is invalid syntax
i been trying different combination for almost 2 hrs without knowing what to do , it is really frustrating.
You need to run first 3 commands you wrote in a system console (e.g.: command prompt on Windows, Terminal on Linux), and the other 2 in a Python console. 'import' lines are Python code that get executed, other 3 lines are scripts your system executes.
Considering the returned error, I guess you attempted to execute all of them in Python console.
It's pip install psycopg2
Windows Python 3.6.1 pip 9.0.1,will find wheel automatic.
(post_gres) E:\1py_div\database\post_gres
λ pip install psycopg2
Collecting psycopg2
 Using cached psycopg2-2.7.1-cp36-cp36m-win32.whl
Installing collected packages: psycopg2
Successfully installed psycopg2-2.7.1
Same for Linux,Python 3.6.1 pip 9.0.1.
(data_env) mint@mint ~/.pyenv/versions/data_env $ pip3 install psycopg2
Collecting psycopg2  
 Downloading psycopg2-2.7.1-cp36-cp36m-manylinux1_x86_64.whl (2.7MB)
   100% |████████████████████████████████| 2.7MB 382kB/s 
Installing collected packages: psycopg2
Successfully installed psycopg2-2.7.1

Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to import sklearn after installing any package ilango 0 1,049 Oct-25-2021, 07:03 AM
Last Post: ilango
  Can't import package hubenhau 1 5,430 Jan-15-2021, 06:23 PM
Last Post: buran
  maintain a postgresql database using osm2pgsql apollo 1 2,082 Aug-03-2020, 10:33 PM
Last Post: Larz60+
  PostgreSQL psycopg2.errors.DuplicateColumn: column specified more than once rajnish_nationfirst 2 3,400 Jun-21-2020, 08:17 AM
Last Post: ibreeden
  StopIteration exception when mock PostgreSQL connection in several tests igor87z 1 2,701 Jun-10-2020, 06:16 PM
Last Post: ibreeden
  import scalalib package doesn't work manu_brighter 2 2,669 Apr-17-2020, 06:36 PM
Last Post: snippsat
  Importing module from a package results in import error goghvv 2 2,142 Mar-27-2020, 07:13 PM
Last Post: goghvv
  Import all items from all modules from package DD169 3 1,878 Jan-25-2020, 12:33 PM
Last Post: buran
  Python and Postgresql syntax select statement Nesreenmhd 1 4,755 Sep-07-2019, 06:08 PM
Last Post: ndc85430
  Create table with psycopg2 on postgreSQL DB yhecohen 2 3,092 Aug-23-2019, 05:56 AM
Last Post: massimo_m

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020