What is error for when install psycopg2==2.7.*? - python

pip3 install psycop2==2.7.*
I try to install Django project on a live server but when I install the package I am getting error! pip install psycopg2==2.7.*

You have to install "headers" for C extension. In this case you should install libpq-dev
sudo apt install libpq-dev

Related

Ubuntu Command 'pip' not found, but there are 18 similar ones (pandas) reintalling works uslly

I tried reinstalling it ,but for us to install pythin packages use the pip's version to specify instaltion for ex pip3 install pandas.
Try to install pip with the following command:
sudo apt-get install python3-pip
Or:
sudo apt-get install python3-dev

Not able to install setuptools on linux mint

I used this command in terminal
sudo apt-get install python-setuptools
it throws up an error instead of installing -
Package 'python-setuptools' has no installation candidate
THis is a python package so you could use pip to install it
pip3 install setuptools
Try this:
sudo apt-get install python-pip
When pip is installed type in:
pip install setuptools
Hope this helps!

Cannot import installed python package

I'm trying to install python-numpy package on my ubuntu 14.04 machine. I ran sudo apt-get install python-numpy command to install it and it says the package has been installed but when i try to access it, i'm unable to do so.
When you type:
sudo pip install package-name
It will default install python2 version of package-name some packages might be supported in both python3 and python3 some might work might not
I would suggest
sudo apt-get install python3-pip
sudo pip3 install MODULENAME
or can even try this
sudo apt-get install curl
curl https://bootstrap.pypa.io/get-pip.py | sudo python3
sudo pip3 install MODULENAME
Many python packages require also the dev package, so install it too:
sudo apt-get install python3-dev
Also check for the sys.path [ make sure module is in the python path ]

You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application

I am working on Django project with virtualenv and connect it to local postgres database. when i run the project is says,
ImportError: No module named psycopg2.extensions
then i used this command to install
pip install psycopg2
then during the installation it gives following error.
Downloading/unpacking psycopg2==2.4.4
Downloading psycopg2-2.4.4.tar.gz (648kB): 648kB downloaded
Running setup.py (path:/home/muhammadtaqi/Projects/MyProjects/OnlineElectionCampaign/venv/build/psycopg2/setup.py) egg_info for package psycopg2
Error: You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/psycopg2.egg-info
writing pip-egg-info/psycopg2.egg-info/PKG-INFO
writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
Error: You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /home/muhammadtaqi/Projects/MyProjects/OnlineElectionCampaign/venv/build/psycopg2
Storing debug log for failure in /home/muhammadtaqi/.pip/pip.log
Use these following commands, this will solve the error:
sudo apt-get install postgresql
then fire:
sudo apt-get install python-psycopg2
and last:
sudo apt-get install libpq-dev
I just run this command as a root from terminal and problem is solved,
sudo apt-get install -y postgis postgresql-9.3-postgis-2.1
pip install psycopg2
or
sudo apt-get install libpq-dev python-dev
pip install psycopg2
Just install libpq-dev
$ sudo apt-get install libpq-dev
For me this simple command solved the problem:
sudo apt-get install postgresql postgresql-contrib libpq-dev python-dev
Then I can do:
pip install psycopg2
For Python 3, I did:
sudo apt install python3-dev postgresql postgresql-contrib python3-psycopg2 libpq-dev
and then I was able to do:
pip3 install psycopg2
They changed the packaging for psycopg2. Installing the binary version fixed this issue for me. The above answers still hold up if you want to compile the binary yourself.
See http://initd.org/psycopg/docs/news.html#what-s-new-in-psycopg-2-8.
Binary packages no longer installed by default. The ‘psycopg2-binary’ package must be used explicitly.
And http://initd.org/psycopg/docs/install.html#binary-install-from-pypi
So if you don't need to compile your own binary, use:
pip install psycopg2-binary
You must setup postgresql-server-dev-X.Y, where X.Y. your's servers version, and it will install libpq-dev and other servers variables at modules for server side developing.
In my case it was
apt-get install postgresql-server-dev-9.5
Reading package lists... Done
Building dependency tree Reading state information... Done The
following packages were automatically installed and are no longer
required: libmysqlclient18 mysql-common Use 'apt-get autoremove' to
remove them. The following extra packages will be installed:
libpq-dev Suggested packages: postgresql-doc-10 The following NEW
packages will be installed: libpq-dev postgresql-server-dev-9.5
In your's case
sudo apt-get install postgresql-server-dev-X.Y
sudo apt-get install python-psycopg2
I was using a virtual environment on Ubuntu 18.04, and since I only wanted to install it as a client, I only had to do:
sudo apt install libpq-dev
pip install psycopg2
And installed without problems. Of course, you can use the binary as other answers said, but I preferred this solution since it was stated in a requirements.txt file.
Run the command below;
sudo apt-get install python-pip python-dev libpq-dev postgresql postgresql-contrib
pip install psycopg2
In my case, I was facing this problem when I ran pip install -r requirements.txt to install all packages for a Django project with PostgreSQL database on an Ubuntu machine, I ran into this error and many other installation errors.
To solve this one, I ran the following commands:
sudo apt install postgresql postgresql-contrib
sudo apt install libpq-dev
sudo apt install python3-dev
sudo apt install python3-pip
sudo apt install python3-psycopg2
pip3 install psycopg2
pip3 install psycopg2-binary
Plus, also check if the Ubuntu and Python and Psycopg versions are compatible together.
Also, pip install aiopg, solve the issue when i ran into it the second time.

How to install SQLAlchemy on Ubuntu?

I want to install Python and SQLAlchemy on Ubuntu. This is my command:
sudo easy_install sqlalchemy
But it has failed, what should I do?
Aha,sir,I can help you.
First step,you should intall the MySql,like these:
sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install libmysqlclient15-dev
Second step,install the python-mysqldb:
sudo apt-get install python-mysqldb
Third step,install the easy_install:
sudo wget http://peak.telecommunity.com/dist/ez_setup.py
sudo python ez_setup.py
Forth step,install the MySQL-Python:
sudo easy_install MySQL-Python
Finally,sqlalchemy:
sudo easy_install SQLAlchemy
I installed it using pip. After installing mysql-server, mysql-client and libmysqlclient15-dev and I ran following commands to install it.
pip install MySql-Python
pip install SQLAlchemy
sudo pip install flask-sqlalchemy
This installs the SQLAlchemy package for Flask.

Categories