Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PostgreSQL- import package
#1
i am trying to use postgreSQL package , i had tried the following:
python -m pip install -U pip setuptools
python get-pip.py
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.
Reply
#2
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.
Reply
#3
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to Connect to PostgreSQL Through Jump Server and SSH Tunnel using Python? nishans 1 837 Jan-02-2024, 10:37 AM
Last Post: khanzain
  Unable to import sklearn after installing any package ilango 0 1,159 Oct-25-2021, 07:03 AM
Last Post: ilango
  Can't import package hubenhau 1 5,863 Jan-15-2021, 06:23 PM
Last Post: buran
  maintain a postgresql database using osm2pgsql apollo 1 2,254 Aug-03-2020, 10:33 PM
Last Post: Larz60+
  PostgreSQL psycopg2.errors.DuplicateColumn: column specified more than once rajnish_nationfirst 2 3,690 Jun-21-2020, 08:17 AM
Last Post: ibreeden
  StopIteration exception when mock PostgreSQL connection in several tests igor87z 1 2,878 Jun-10-2020, 06:16 PM
Last Post: ibreeden
  import scalalib package doesn't work manu_brighter 2 2,840 Apr-17-2020, 06:36 PM
Last Post: snippsat
  Importing module from a package results in import error goghvv 2 2,340 Mar-27-2020, 07:13 PM
Last Post: goghvv
  Import all items from all modules from package DD169 3 2,052 Jan-25-2020, 12:33 PM
Last Post: buran
  Python and Postgresql syntax select statement Nesreenmhd 1 4,937 Sep-07-2019, 06:08 PM
Last Post: ndc85430

Forum Jump:

User Panel Messages

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