How to install libffi-dev and libssl-dev on Windows - python

I am trying to run a piece of code using paramiko, but I get the error message ImportError: No module named cryptography.hazmat.backends. Both paramiko and cryptography are already installed.
As far as I can read on various forums, I need to install libffi-dev (and maybe also libssl-dev). However, all solutions I can find are either for Ubuntu or Mac OS. How do I install them on Windows 10?

Solved the issue by running
pip install cryptography --force-reinstall
and
pip install paramiko --force-reinstall

Related

pip install paramiko comes out with error - ModuleNotFoundError: No module named 'zlib' [duplicate]

I was trying to install Django. Turns out that course's teacher said that we will be working with Python 3.6
I install Python 3.6. Now it's my default, it somewhat replaced the last version I had; which is Python 3.5.
Everything ok until that. But when I want to install Django doing
"pip3 install django", it tells me that the module is already satisfied and therefore installed.
I run "python3" command into my terminal. It runs Python 3.6. I try to import Django, and boom... "No module named 'django'".
Then I realized pip3 was actually installing my modules into Python 3.5 and not 3.6. So what I do is to install pip in Python 3.6.
I download get-pip.py and proceed to execute it with Python 3.6 typing in "python3.6 get-pip.py".
Here is when the damn "zipimport.ZipImportError: can't decompress data; zlib not available" goes in. I've tried a ton of things and no one of them fixed the %^$! problem. I'm really tired.
What I have already tried:
python3.6 -m pip install django, which output is "/usr/local/bin/python3.6: No module named pip"
apt install zlib, which output is "E: Unable to locate package zlib"
apt install zlib1g-dev, which says that it's already installed; the problem persists though.
I also came across this problem (while creating a simple installer for pyenv). Here's how I solved it for Mac and Linux:
Ubuntu 20.04, 18.04
You need the zlib development files, and probably zlib itself too:
sudo apt install -y zlib1g-dev zlibc
If you're missing zlib, it's likely that the next problem you'll run into is with openssl, so it's probably best to get that now as well:
sudo apt install -y libssl-dev
sudo apt install -y libssl1.1 || sudo apt install -y libssl1.0
macOS
I believe this comes with XCode CLI Tools (or at least I didn't have to custom install it Big Sur):
xcode-select --install
For me it worked in RHEL:
$ yum install zlib-devel
Suggested solutions (installing zlib1g-dev or zlib-devel) seem to resolve the issue in most cases. Here is one edge case I've encountered recently: whatever you are trying to run might use zlib via symlink which might be broken.
In my case I was trying to run a build of a 3rd-party software which already had python and all necessary libs being emebedded into it. It was packaged as a tar.gz archive. Unpacking the archive on a Windows machine and then copying the contents to another linux machine destroyed all the symlinks (if you do ls -l in a folder with symlinks you would see that all of them have size 0 and do not point to anything). Copying tar.gz to the linux machine directly and unpacking it there resolved the issue.
P.S. I know it's an edge case scenario but it took me and one more developer quite a while to figure it out so I think it's worth mentioning here, just in case someone gets as unlucky as I got.
Its solves my issue for centos 7.6 :-
yum install zlib-deve

Not able to install package because pip is not installed

I am running Ubuntu and have both python 2.7 and python 3.5 on my system
I have tweaked the settings so that when I do
python test.py
python3 runs
I wanted to install the module pyperclip in python3..
pip install pyperclip
installed it for python 2
Quick google search suggested to use
pip3 install pyperclip
but I get
pip3 is currently not installed . You can install it by typing
sudo apt install python3-pip
When I run this command I get the following:
The following packages have unmet dependencies:
python3-pip : Depends: python-pip-whl (= 8.1.1-2) but 8.1.1- 2ubuntu0.2 is to be installed
Recommends: python3-dev (>= 3.2) but it is not going to be installed
Recommends: python3-setuptools but it is not going to be installed
Recommends: python3-wheel but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
What should I do?
It seems like it could be an error in your path. If you installed Python 3.5 it should come with pip, so try doing python -m pip and this should run Python 3.5's pip. To install something, simply use the normal pip commands as you have, for example python -m pip install pyperclip.
Use the aptitude package manager as it will provide you simple suggestion to fix your unmet dependencies problem. Install it via apt:
sudo apt-get install aptitude
Then install pip3 with this command:
sudo aptitude install python3-pip
Then choose the solution suggested to you by aptitude. In one of the suggestions aptitude will suggest you to downgrade from 8.1.1-2ubuntu0.2 to 8.1.1-2. Accepting this suggestion solves the issue. Just make sure the downgrade doesn't cause you other hurdles.

Python Programming with raspberry Pi...Import mysqldb error

update Error Installation ErrorI am trying to access a database using python.when i am executing my script its giving error, Import Error:-No module named MySQL . I have even tried it to run with lower versions of python but the same error came.I tried to install the MySQL package using the command sudo apt-get install python-mysqldb but it throwing some error.
So i write a answer, so that the question could be marked as "answered".
The problem was losing internet connection. APT need internet connection to download the packages from source.
For someone, who want to install python module MySQLDB in Debian or Ubuntu:
apt-get update
apt-get install python-mysqldb
If you want to install MySQLDB from pip, you need to install all the prerequisites for python-mysqldb first (for virtualenv)
apt-get build-dep python-mysqldb
pip install mysql-python

ImportError: The 'enchant' C library was not found. Please install it via your OS package manager, or use a pre-built binary wheel from PyPI

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.

SSL backend error when using OpenSSL

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"

Categories

Resources