Related
The question is why I see the error message in the title when trying to import enchant. I am using Win64.
On Ubuntu, run sudo apt-get install libenchant1c2a
I found the answer in this GitHub page.
In a nutshell, they have not shipped a wheel for the win_amd64 platform yet.
Resolved: On Win7-64 I ran
pip3 install pyenchant==1.6.6
which seems to be the latest version of PyEnchant that still shipped with Win-64 binaries. Newer versions did not install for me, but this one did.
For amazon ubuntu instance use.
yum install enchant
and then
pip install pyenchant
For me, the problem I ran into was that I had an old version of pip. I installed the latest version and was able to download the pyenchant library.
pip install -U pip
On Windows x64 I've solved this problem as follows:
Click link https://pypi.org/project/pyenchant/#files and download pyenchant-2.0.0.win32.exe
Launch it and while installing it using the installation wizard you must specify your python interpreter location which in my case is:
C:\Users\Asus\AppData\Local\Programs\Python\Python36\python.exe
Important:İf you use python32 interpreter you must specify this location:
C:\Users\Asus\AppData\Local\Programs\Python\Python36-32\python.exe
if you use python 3.5 interpreter version your location may be like this:
C:\Users\Asus\AppData\Local\Programs\Python\Python35\python.exe
and finish the installation. Pip commands will work now for other dependency packages.
On MacOS, you can install it via brew:
brew install enchant
pip install pyenchant
To run with docker on AWS:
With apt-get:
sudo apt-get update
sudo apt-get -y install enchant-2
With apt:
sudo apt update
sudo apt -y install enchant-2
Thank you
I have fix the bugs on the colab.
!apt update
!apt install enchant --fix-missing
After fixing the missing files, you could run the enchant.
I was trying to install pycurl in a virtualenv using pip and I got this error
ImportError: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (none/other)
I read some documentation saying that "To fix this, you need to tell setup.py what SSL backend is used" (source) although I am not sure how to do this since I installed pycurl using pip.
How can I specify the SSL backend when installing pycurl with pip?
Thanks
for most people
After reading their INSTALLATION file, I was able to solve my problem by setting an environment variable and did a reinstall
# remove existing `pycurl` installation
pip uninstall pycurl
# export variable with your link-time ssl backend (which is openssl above)
export PYCURL_SSL_LIBRARY=openssl
# then, re-install `pycurl` with **no cache**
pip install pycurl --no-cache-dir
There could be other solution out there but this works perfectly for me on a virtualenv and pip installation.
Some people have a different error message complaining about nss instead of openssl
ImportError: pycurl: libcurl link-time ssl backend (nss)
(the key part is nss) so you have to do something different for this error message:
pip uninstall pycurl
pip install --no-cache-dir --compile --compile-options="--with-nss" pycurl
helloworld2013's answer is correct, but the key is matching the SSL library that pycurl is expecting. The error will be something like:
pycurl: libcurl link-time ssl backend (<library>) is different from compile-time ssl backend (<library> or "none/other")
To fix it, you have to use the library pycurl is expecting. In my case, my error was "pycurl: libcurl link-time ssl backend (nss) is different from compile-time ssl backend (openssl)", so my fix was:
pip uninstall pycurl
export PYCURL_SSL_LIBRARY=nss
pip install pycurl
With macOS 10.13, a brew-installed openSSL, and virtualenv, I was successful with:
# cd to your virtualenv, then…
pip uninstall pycurl
export PYCURL_SSL_LIBRARY=openssl
export LDFLAGS=-L/usr/local/opt/openssl/lib
export CPPFLAGS=-I/usr/local/opt/openssl/include
pip install pycurl --compile --no-cache-dir
With pip 7.1 you can put the following in your requirements file:
pycurl==7.19.5.1 --global-option="--with-nss"
Simply replace nss with the relevant ssl backend library.
The method to fix the pycurl after Mac OS High Sierra update:
Reinstall the curl libraries to use OpenSSL instead of SecureTransport
brew install curl --with-openssl
Install pycurl with correct build-time environment and paths
export PYCURL_SSL_LIBRARY=openssl
pip uninstall pycurl
pip install --no-cache-dir --global-option=build_ext --global-option="-L/usr/local/opt/openssl/lib" --global-option="-I/usr/local/opt/openssl/include" --user pycurl
This worked for me:
pip uninstall pycurl
export PYCURL_SSL_LIBRARY=nss
easy_install pycurl
None of this worked for me (note the difference is simply easy_install vs pip):
pip uninstall pycurl
export PYCURL_SSL_LIBRARY=[nss|openssl|ssl|gnutls]
pip install pycurl
#xor
curl -O https://pypi.python.org/packages/source/p/pycurl/pycurl-7.19.3.1.tar.gz
#...
python setup.py --with-[nss|openssl|ssl|gnutls] install
I had this problem for days. Finally with the help of other answers here (mainly Alexander Tyapkov's) I got it working for AWS Elastic Beanstalk.
Manual install (connecting with SSH):
sudo pip uninstall pycurl
curl -O https://pypi.python.org/packages/source/p/pycurl/pycurl-7.43.0.tar.gz
sudo pip install pycurl-7.43.0.tar.gz --global-option="--with-nss"
IMPORTANT: Please note that you have to make sure you are using the currect version of Python and PIP, otherwise you might be compiling it for Python 2.x and using v3.x.
Auto-install in Elastic Beanstalk:
files:
"/usr/local/share/pycurl-7.43.0.tar.gz" :
mode: "000644"
owner: root
group: root
source: https://pypi.python.org/packages/source/p/pycurl/pycurl-7.43.0.tar.gz
commands:
01_download_pip3:
# run this before PIP installs requirements as it needs to be compiled with OpenSSL
command: 'curl -O https://bootstrap.pypa.io/get-pip.py'
02_install_pip3:
# run this before PIP installs requirements as it needs to be compiled with OpenSSL
command: 'python3 get-pip.py'
03_pycurl_uninstall:
# run this before PIP installs requirements as it needs to be compiled with OpenSSL
command: '/usr/bin/yes | sudo pip uninstall pycurl'
04_pycurl_download:
# run this before PIP installs requirements as it needs to be compiled with OpenSSL
command: 'curl -O https://pypi.python.org/packages/source/p/pycurl/pycurl-7.43.0.tar.gz'
05_pycurl_reinstall:
# run this before PIP installs requirements as it needs to be compiled with OpenSSL
command: 'sudo pip install pycurl-7.43.0.tar.gz --global-option="--with-nss"'
container_commands:
09_pycurl_reinstall:
# run this before PIP installs requirements as it needs to be compiled with OpenSSL
# the upgrade option is because it will run after PIP installs the requirements.txt file.
# and it needs to be done with the virtual-env activated
command: 'source /opt/python/run/venv/bin/activate && pip3 install /usr/local/share/pycurl-7.43.0.tar.gz --global-option="--with-nss" --upgrade'
I had this problem because I was trying to configure Celery 4 with Django 1.10 in Elastic Beanstalk. If that's your case, I wrote a full blog post about it.
I'm on CentOS 7. I tried all of the above and couldn't get anything to work. It turns out I needed to run these as a root user. So if you're having trouble, try any of the above solutions as a root user. As an example, here is what worked for me:
su -
pip uninstall pycurl
export PYCURL_SSL_LIBRARY=[nss|openssl|ssl|gnutls]
pip install pycurl
Of course, all the usual disclaimers about running as a root user apply.
Note: [nss|openssl|ssl|gnutls] in the code above means to pick one, and don't include the square brackets or pipes. The person who asked the original question would have chosen openssl. In my particular case, I chose nss. Your error message should tell you which choice to make.
2019 Edit: Doing a sudo pip install might cause a problem with the machine's system install of Python. Perhaps try working in a Python virtual environment and install the packages there. If that doesn't work, the sudo trick in my answer is probably one of the last options to consider.
You can download the tar.gz file from here. Then extract it into a folder. You'll find a setup.py file there. Run the command over there that the site mentioned. For example:
python setup.py --with-[ssl|gnutls|nss] install
FYI: I tried to install pycurl at my windows, but I couldn't. But did it on my linux.
I am running this on OS X and some of the above solutions weren't working. Similar to Edward Newell's comment the PYCURL_SSL_LIBRARY variable seemed to have been completely ignored.
Further reading of the PycURL installation doc revealed the following:
pip may reinstall the package it has previously compiled instead of recompiling pycurl with newly specified options
Therefore, I had to force it to compile with:
pip install --compile pycurl
That works on a number of cases. However, I did run into a few systems that continued to ignore the variable so, similar to maharg101's answer, I resorted to the install options which through pip can be set like this:
pip install pycurl --global-option="--with-[ssl|gnutls|nss]"
where you select one of the three options inside the square brackets. Notice that the available option is ssl and not openssl. If you specify --with-openssl you'll get an error. Also note that if you were messing around with the PYCURL_SSL_LIBRARY variable and switching it to funky values to see what would happen this last command will definitely catch it and throw an error if the value is set but not valid.
For anyone having problem inside PyCharm CE on macOS
Mojave this is how i got it working in venv:
specify version: 7.43.0.1
Options: --install-option=--with-openssl --install-option=--openssl-dir=/usr/local/opt/openssl
Reinstallation of curl
I tried every suggestion from this discussion but no one worked for me. As solution I have reinstalled curl and curlib. After that I was able to install pycurl with ssl support inside environment.
At start:
'PycURL/7.43.0 libcurl/7.47.0 GnuTLS/3.4.10 zlib/1.2.8 libidn/1.32
librtmp/2.3'
Part 1.Re/Installation with pip
Firstly I have removed pycurl from virtualenv using pip as was suggested previous answers:
pip uninstall pycurl
export PYCURL_SSL_LIBRARY=openssl
pip install pycurl --global-option="--with-openssl"
The idea here is that package was cached and we just reintstall it with openssl option.
I also tried to recompile pycurl with pip using:
pip install pycurl --compile pycurl --no-cache
..but had the same error after running:
python
import pycurl
pycurl.version
ImportError: pycurl: libcurl link-time ssl backend (gnutls) is
different from compile-time ssl backend (openssl)
Part 2. Installation from tar
After previous method didn't work I have decidede to install pycurl from tar with:
curl -O https://pypi.python.org/packages/source/p/pycurl/pycurl-7.43.0.tar.gz
sudo tar -xzvf pycurl-7.43.0.tar.gz
cd pycurl-7.43.0/
sudo python setup.py --with-ssl install
It has installed pycurl globally but not within virtualenv. I also didn't check if it was installed with SSL support or not but think that still without ssl.
Part 3. Reinstallation of curl and curllib
Finally I understood that pycurl doesn't installs normally into environment because global curl and libcurl are compiled with gnutls.
Before starting check it with:
curl-config --configure
One of the output lines will be
'--without-ssl' '--with-gnutls'
To recompile it:
Firstly remove curl:
sudo apt-get purge curl
Install any build dependencies needed for curl
sudo apt-get build-dep curl
Get latest (as of Dec 20, 2016) libcurl
mkdir ~/curl
wget http://curl.haxx.se/download/curl-7.51.0.tar.bz2
tar -xvjf curl-7.51.0.tar.bz2
cd curl-7.51.0
The usual steps for building an app from source
./configure
./make
sudo make install
If openssl installed correctly then configure will find it automatically. The output will be:
curl version: 7.51.0
Host setup: x86_64-pc-linux-gnu
Install prefix: /usr/local
Compiler: gcc
SSL support: enabled (OpenSSL) ...
Resolve any issues of C-level lib location caches ("shared library cache")
sudo ldconfig
Now try to reinstall pycurl within environment:
curl -O https://pypi.python.org/packages/source/p/pycurl/pycurl-7.43.0.tar.gz
pip install pycurl-7.43.0.tar.gz --global-option="--with-openssl"
The result should be:
python
import pycurl
pycurl.version
'PycURL/7.43.0 libcurl/7.51.0 OpenSSL/1.0.2g zlib/1.2.8 librtmp/2.3'
I tried everything here on macOS 10.13 with no success. Then I found https://gist.github.com/webinista/b4b6a4cf8f158431b2c5134630c2cbfe which worked:
brew install curl --with-openssl
pip uninstall pycurl
export PYCURL_SSL_LIBRARY=openssl
export LDFLAGS=-L/usr/local/opt/openssl/lib;export CPPFLAGS=-I/usr/local/opt/openssl/include; pip install pycurl --compile --no-cache-dir
This worked for me both when not using a virtualenv and within a virtualenv.
This worked for me:
pip install --compile --install-option="--with-openssl" pycurl
Not sure if this is because of running in a virtualenv, but on CentOS 7 these solutions weren't working for me; the compiled objects were still being grabbed from the cache dir when I was reinstalling. If you're running into the same problem after trying other solutions here, try the following:
pip uninstall pycurl
export PYCURL_SSL_LIBRARY=[nss|openssl|ssl|gnutls]
pip install pycurl --no-cache-dir
Error:
ImportError: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (none/other)
This worked for me, Mac 10.13, python 3.5, pycurl import worked after installing like this
pip3 uninstall pycurl;
pip3 install --compile --install-option="--with-openssl" pycurl
After being stuck on this for a long time, I found out that apple stopped including OpenSSL headers since OS X 10.11 El Capitan.
how to fix?
1) brew install openssl
2) echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile (or .zshrc for zsh, etc)
3) pip uninstall pycurl
4) pip install --install-option="--with-openssl" --install-option="--openssl-dir=/usr/local/opt/openssl" pycurl
Same problem on amazonlinux - solved
I had this problem while creating a docker image based on amazonlinux, installing python3.7 and adding the pycurl module.
All other python modules were installed correctly except pycurl.
After trying many of the solutions proposed in the threads linked to this problem I finally solved my problem by using following commands for installation of all the pieces.
yum -y install python3 python3-devel gcc libcurl-devel aws-cli openssl-static.x86_64
then installed other modules like psycopg2-binary, requests, certifi using:
pip3 install --user --no-cache-dir -r requirements.txt
and finally installed pycurl module using:
pip3 install --user --global-option="--with-openssl" --no-cache-dir pycurl
and passing here the openssl global option.
The installation of the static library openssl-static.x86_64 solved the problem in my case as using global option used by the second pip3 command.
For python 2.7
sudo apt-get install build-essential libssl-dev libffi-dev python-dev
For python 3.5 also install the next:
sudo apt-get install python3.5-dev
Download the latest pycurl-7.43.0.tar.gz (md5) Source from pypi https://pypi.python.org/pypi/pycurl/7.43.0#downloads
and run the next command:
python setup.py --with-openssl install
Also you can do it into python environment:
(test_env)user#pc:~/Downloads/pycurl-7.43.0$ python setup.py --with-openssl install
pip install -U pip
if [ "$(curl --version | grep NSS 2>/dev/null)" ]; then
pip install --compile --install-option="--with-nss" pycurl
else
pip install --compile --install-option="--with-openssl" pycurl
fi
I encountered this problem and Sanket Jagtap's answer worked for me. I tried the answer with the most votes answer but it did not work.
My openssl old version is 1.0.1t, I think reinstalling openssl may solve this problem.
--- pycurl's openssl backend time....
I rebuilt the latest openssl and tried this answer. Check this out.
pip install --compile --install-option="--with-openssl" pycurl
This worked for me.
i recommend we should reinstall our openssl for try..
Following worked for me with Python3.6
MacOS High-Sierra
sudo pip3 uninstall pycurl
sudo pip3 install --compile --install-option="--with-openssl" pycurl
CentOS 7
sudo pip3 uninstall pycurl
sudo pip3 install --compile --install-option="--with-nss" pycurl
This link sums up the reason why the errors occur and gives a clear instruction to fix the problem.
https://cscheng.info/2018/01/26/installing-pycurl-on-macos-high-sierra.html
For me, the problem occurred when I upgraded to High-Sierra from El
Captain.
FWIW, I ran into a lot of issues getting this working via AWS Elastic Beanstalk and finally was able to get it working with:
packages:
yum:
openssl-devel: []
libcurl-devel: []
container_commands:
# Reinstall PyCurl with correct ssl backend
05_reinstall_pycurl:
command: |
pip install --upgrade pip
pip uninstall -y pycurl
pip install --global-option='--with-openssl' pycurl
Recently while upgrading a Django project I had the similar error. But this time setting the environment variable did not work. So I had to set both environment variable export PYCURL_SSL_LIBRARY=openssl and pass the flag --global-option="with-openssl".
The original answer was posted on this page
export CPPFLAGS=-I/usr/local/opt/openssl/include
export LDFLAGS=-L/usr/local/opt/openssl/lib
pip install pycurl --global-option="--with-openssl"
I tried importing requests:
import requests
But I get an error:
ImportError: No module named requests
Requests is not a built in module (does not come with the default python installation), so you will have to install it:
OSX/Linux
Python 2: sudo pip install requests
Python 3: sudo pip3 install requests
if you have pip installed (pip is the package installer for python and should come by default with your python installation).
If pip is installed but not in your path you can use python -m pip install requests (or python3 -m pip install requests for python3)
Alternatively you can also use sudo easy_install -U requests if you have easy_install installed.
Linux
Alternatively you can use your systems package manager:
For centos: sudo yum install python-requests
For Debian/Ubuntu Python2: sudo apt-get install python-requests
For Debian/Ubuntu Python3: sudo apt-get install python3-requests
Windows
Use pip install requests (or pip3 install requests for python3) if you have pip installed and Pip.exe added to the Path Environment Variable. If pip is installed but not in your path you can use python -m pip install requests (or python3 -m pip install requests for python3)
Alternatively from a cmd prompt, use > Path\easy_install.exe requests, where Path is your Python*\Scripts folder, if it was installed. (For example: C:\Python32\Scripts)
If you manually want to add a library to a windows machine, you can download the compressed library, uncompress it, and then place it into the Lib\site-packages folder of your python path. (For example: C:\Python27\Lib\site-packages)
From Source (Universal)
For any missing library, the source is usually available at https://pypi.python.org/pypi/. You can download requests here: https://pypi.python.org/pypi/requests
On mac osx and windows, after downloading the source zip, uncompress it and from the termiminal/cmd run python setup.py install from the uncompressed dir.
(source)
It's not obvious to me which version of Python you are using.
If it's Python 3, a solution would be sudo pip3 install requests
To install requests module on Debian/Ubuntu for Python2:
$ sudo apt-get install python-requests
And for Python3 the command is:
$ sudo apt-get install python3-requests
Brew users can use reference below,
command to install requests:
python3 -m pip install requests
Homebrew and Python
pip is the package installer for Python and you need the package requests.
This may be a liittle bit too late but this command can be run even when pip path is not set. I am using Python 3.7 running on Windows 10 and this is the command
py -m pip install requests
and you can also replace 'requests' with any other uninstalled library
If you are using Ubuntu, there is need to install requests
run this command:
pip install requests
if you face permission denied error, use sudo before command:
sudo pip install requests
In my case requests was already installed, but needed an upgrade. The following command did the trick
$ sudo pip install requests --upgrade
On OSX, the command will depend on the flavour of python installation you have.
Python 2.x - Default
sudo pip install requests
Python 3.x
sudo pip3 install requests
On Windows Open Command Line
pip3 install requests
I had the same issue, so I copied the folder named "requests" from https://pypi.python.org/pypi/requests#downloadsrequests download to
"/Library/Python/2.7/site-packages".
Now when you use: import requests, it should work fine.
In the terminal/command-line:
pip install requests
then use it inside your Python script by:
import requests
or else if you want to use pycharm IDE to install a package:
go to setting from File in menu
next go to Python interpreter
click on pip
search for requests package and install it
Adding Third-party Packages to the Application
Follow this link
https://cloud.google.com/appengine/docs/python/tools/libraries27?hl=en#vendoring
step1 : Have a file by named a file named appengine_config.py in the root of your project, then add these lines:
from google.appengine.ext import vendor
Add any libraries installed in the "lib" folder.
vendor.add('lib')
Step 2: create a directory and name it "lib" under root directory of project.
step 3: use pip install -t lib requests
step 4 : deploy to app engine.
Try sudo apt-get install python-requests.
This worked for me.
If you are using anaconda as your python package manager, execute the following:
conda install -c anaconda requests
Installing requests through pip didn't help me.
The only thing that worked for me:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
pip install requests
Facing the same issue but unable to fix it with the above solution, so I tried this way and it worked:-
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
sudo python2 get-pip.py
python -m pip install requests
For windows just give path as cd and path to the "Scripts" of python and then execute the command easy_install.exe requests.Then try import requests...
I have had this issue a couple times in the past few months. I haven't seen a good solution for fedora systems posted, so here's yet another solution. I'm using RHEL7, and I discovered the following:
If you have urllib3 installed via pip, and requests installed via yum you will have issues, even if you have the correct packages installed. The same will apply if you have urllib3 installed via yum, and requests installed via pip. Here's what I did to fix the issue:
sudo pip uninstall requests
sudo pip uninstall urllib3
sudo yum remove python-urllib3
sudo yum remove python-requests
(confirm that all those libraries have been removed)
sudo yum install python-urllib3
sudo yum install python-requests
Just be aware that this will only work for systems that are running Fedora, Redhat, or CentOS.
Sources:
This very question (in the comments to this answer).
This github issue.
Python Common installation issues
These commands are also useful if Homebrew screws up your path on macOS.
python -m pip install requests
or
python3 -m pip install requests
Multiple versions of Python installed in parallel?
You must make sure your requests module is not being installed in a more recent version of python.
When using python 3.7, run your python file like:
python3 myfile.py
or enter python interactive mode with:
python3
Yes, this works for me. Run your file like this: python3 file.py
I have installed python2.7 and python3.6
Open Command Line to ~/.bash_profile I find that #Setting PATH for Python 3.6 , So
I change the path to PATH="/usr/local/Cellar/python/2.7.13/bin:${PATH}" ,
(please make sure your python2.7's path) ,then save.
It works for me.
if you want request import on windows:
pip install request
then beautifulsoup4 for:
pip3 install beautifulsoup4
Please try the following. If one doesn't work, skip to the next method.
pip install requests
or...
pip3 install requests
or...
python -m pip install requests
or...
python3 -m pip install requests
or...
python -m pip3 install requests
If all of these don't work, please leave a comment!
How does this work? Depending on the operating system you currently use, the pip command may vary or not work on some. These are the commands you may try in order for a fix.
In case you hit pip install requests and had an output massage of Requirement already satisfied but yet you still get the error: ImportError: No module named requests.
This is likely to happen when you find yourself in a different interpreter/virtual environment.
You can copy and append the path of the module into your working environment.
Note: This path usually comes with the message Requirement already satisfied
Before import requests, you should import sys and then append the copied path.
Example:
Command Prompt:
pip install requests
Output:
Requirement already satisfied: requests in /usr/local/lib/python3.9/site-packages
import sys
sys.path.append("/usr/local/lib/python3.9/site-packages")
import requests
I solved this problem.You can try this method.
In this file '.bash_profile', Add codes like alias python=/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Type this command in Command Prompt (Windows) or Terminal (Linux/macOS):
pip install requests
My answer is basically the same as #pi-k. In my case my program worked locally but failed to build on QA servers. (I suspect devops had older versions of the package blocked and my version must have been too out-of-date) I just decided to upgrade everything
$ pip install pip-review
$ pip-review --local --interactive
You get an import error because requests are not a built-in module instead, it is created by someone else and you need to install the requests.
use the following command on your terminal then it will work correctly.
pip install requests
Install python requests library and this error will be solved.
I found that my issue was VSCode was reading from the wrong Python Interpreter. This youtube tutorial solved it for me.
If you are using anaconda
step 1:
where python
step 2:
open anaconda prompt in administrator mode
step 3:
cd <python path>
step 4:
install the package in this location
In installation process of OpenERP 6, I want to generate a config file with these commands:
cd /home/openerp/openerp-server/bin/
./openerp-server.py -s --stop-after-init -c /home/openerp/openerp-server.cfg
But it always showed the message: ImportError: No module named psycopg2
When I checked for psycopg2 package, it's already installed. Package python-psycopg2-2.4.5-1.rhel5.x86_64 is already installed to its latest version. Nothing to do. What's wrong with this? My server is CentOS, I've installed Python 2.6.7.
Step 1: Install the dependencies
sudo apt-get install build-dep python-psycopg2
Step 2: Run this command in your virtualenv
pip install psycopg2-binary
Ref: Fernando Munoz
Use psycopg2-binary instead of psycopg2.
pip install psycopg2-binary
Or you will get the warning below:
UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: http://initd.org/psycopg/docs/install.html#binary-install-from-pypi.
Reference: Psycopg 2.7.4 released | Psycopg
I faced the same issue and resolved it with following commands:
sudo apt-get install libpq-dev
pip install psycopg2
Try installing
psycopg2-binary
with
pip install psycopg2-binary --user
Please try to run the command import psycopg2 on the python console. If you get the error then check the sys.path where the python look for the install module. If the parent directory of the python-psycopg2-2.4.5-1.rhel5.x86_64 is there in the sys.path or not. If its not in the sys.path then run export PYTHONPATH=<parent directory of python-psycopg2-2.4.5-1.rhel5.x86_64> before running the openerp server.
Import Error on Mac OS
If psycopg2 is getting installed but you are unable to import it in your .py file then the problem is libpq, its linkages, and the library openssl, on which libpq depends upon. The overall steps are reproduced below. You can check it step by step to know which is the source of error for you and then you can troubleshoot from there.
Check for the installation of the openssl and make sure it's working.
Check for installation of libpq in your system it may not have been installed or not linked. If not installed then install it using the command brew install libpq. This installs libpq library. As per the documentation
libpq is the C application programmer's interface to PostgreSQL. libpq is a set of library functions that allow client programs to pass queries to the PostgreSQL backend server and to receive the results of these queries.
Link libpq using brew link libpq, if this doesn't work then use the command: brew link libpq --force.
Also put in your .zshrc file the following export PATH="/usr/local/opt/libpq/bin:$PATH". This creates all the necessary linkages for libpq library .
Now restart the terminal or use the following command source ~/.zshrc.
Now use the command pip install psycopg2. It will work.
This works, even when you are working in conda environment.
N.B. pip install psycopg2-binaryshould be avoided because as per the developers of the psycopg2 library
The use of the -binary packages in production is discouraged because in the past they proved unreliable in multithread environments. This might have been fixed in more recent versions but I have never managed to reproduce the failure.
Try with these:
virtualenv -p /usr/bin/python3 test_env
source test_env/bin/activate
pip install psycopg2
run python and try to import if you insist on installing it on your systems python try:
pip3 install psycopg2
Recently faced this issue on my production server. I had installed pyscopg2 using
sudo pip install psycopg2
It worked beautifully on my local, but had me for a run on my ec2 server.
sudo python -m pip install psycopg2
The above command worked for me there. Posting here just in case it would help someone in future.
sudo pip install psycopg2-binary
You need to install the psycopg2 module.
On CentOS:
Make sure Python 2.7+ is installed. If not, follow these instructions: http://toomuchdata.com/2014/02/16/how-to-install-python-on-centos/
# Python 2.7.6:
$ wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz
$ tar xf Python-2.7.6.tar.xz
$ cd Python-2.7.6
$ ./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
$ make && make altinstall
$ yum install postgresql-libs
# First get the setup script for Setuptools:
$ wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
# Then install it for Python 2.7 and/or Python 3.3:
$ python2.7 ez_setup.py
$ easy_install-2.7 psycopg2
Even though this is a CentOS question, here are the instructions for Ubuntu:
$ sudo apt-get install python3-pip python-distribute python-dev
$ easy_install psycopg2
Cite: http://initd.org/psycopg/install/
For python3 on ubuntu, this worked for me:
$sudo apt-get update
$sudo apt-get install libpq-dev
$sudo pip3 install psycopg2-binary
i have the same problem, but this piece of snippet alone solved my problem.
pip install psycopg2
Run into the same issue when I switch to Ubuntu from Windows 10.. the following worked for me.. this after googling and trying numerous suggestions for 2 hours...
sudo apt-get install libpq-dev
then
pip3 install psycopg2
I hope this helps someone who has encountered the same problem especially when switching for windows OS to Linux(Ubuntu).
I have done 2 things to solve this issue:
use Python 3.6 instead of 3.8.
change Django version to 2.2 (may be working with some higher but I change to 2.2)
For Python3
Step 1: Install Dependencies
sudo apt-get install python3 python-dev python3-dev
Step 2: Install
pip install psycopg2
check correctly if you had ON your virtual env of your peoject, if it's OFF then make it ON. execute following cammands:
workon <your_env_name>
python manage.py runserver
It's working for me
It's very simple, not sure why nobody mentioned this for mac before.
brew install postgresql
pip3 install psycopg2
In simple terms, psycopg2 wants us to install postgres first.
PS: Don't forget to upvote, so that it can help other people as well.
Solved the issue with below solution :
Basically the issue due to _bz2.cpython-36m-x86_64-linux-gnu.so Linux package file. Try to find the the location.
Check the install python location ( which python3)- Example: /usr/local/bin/python3
copy the file under INSTALL_LOCATION/lib/python3.6
cp -rvp /usr/lib64/python3.6/lib-dynload/_bz2.cpython-36m-x86_64-linux-gnu.so /usr/local/lib/python3.6
try:
pip install psycopg2 --force-reinstall --no-cache-dir
Python2 importerror no module named psycopg2
pip install psycopg2-binary
Requirement already satisfied...
Solved by following steps:
sudo curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
sudo python get-pip.py
sudo python -m pip install psycopg2-binary
pip install psycopg-binary
The line above helped me
For Python3 use this:
sudo apt-get install -y python3-psycopg2
I've seen it documented that you can install a Github hosting Python package using pip via:
sudo pip install -e git+git://github.com/myuser/myproject.git#egg=myproject
However, this appears to install the package to the current working directory, which is almost never where is should be.
How do you instruct pip to install it into the standard Python package directory (e.g. on Ubuntu this is /usr/local/lib/python2.6/dist-packages)?
The -e flag tells pip to install it as "editable", i.e. keep the source around. Drop the -e flag and it should do about what you expect.
sudo pip install git+git://github.com/myuser/myproject.git#egg=myproject
If that doesn't work try using https instead of git.
sudo pip install git+https://github.com/myuser/myproject.git#egg=myproject
For Python 3 make sure you have python3-pip installed (and of course git installed):
The syntax just changed to:
sudo pip3 install git+git://github.com/someuser/someproject.git