Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (none/other) #4

Closed
vmihalachi opened this issue Nov 24, 2017 · 19 comments

Comments

@vmihalachi
Copy link

Hi, we are using trying to run the tutorial https://transloadit.com/demos/file-importing/import-a-file-over-http/.
When we start the server, an error occurs. Do you know what is causing it?

This is our setup:

  • Python 3.6
  • Tranloadit 0.1.7
  • Django 1.11.7

Error:
ImportError: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (none/other)

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x1031b1378>
Traceback (most recent call last):
  File "/Users/mac/.local/share/virtualenvs/clickandrap-0ABdElTc/lib/python3.6/site-packages/django/utils/autoreload.py", line 228, in wrapper
    fn(*args, **kwargs)
  File "/Users/mac/.local/share/virtualenvs/clickandrap-0ABdElTc/lib/python3.6/site-packages/sslserver/management/commands/runsslserver.py", line 118, in inner_run
    self.check(display_num_errors=True)
  File "/Users/mac/.local/share/virtualenvs/clickandrap-0ABdElTc/lib/python3.6/site-packages/django/core/management/base.py", line 359, in check
    include_deployment_checks=include_deployment_checks,
  File "/Users/mac/.local/share/virtualenvs/clickandrap-0ABdElTc/lib/python3.6/site-packages/django/core/management/base.py", line 346, in _run_checks
    return checks.run_checks(**kwargs)
  File "/Users/mac/.local/share/virtualenvs/clickandrap-0ABdElTc/lib/python3.6/site-packages/django/core/checks/registry.py", line 81, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/Users/mac/.local/share/virtualenvs/clickandrap-0ABdElTc/lib/python3.6/site-packages/django/core/checks/urls.py", line 16, in check_url_config
    return check_resolver(resolver)
  File "/Users/mac/.local/share/virtualenvs/clickandrap-0ABdElTc/lib/python3.6/site-packages/django/core/checks/urls.py", line 26, in check_resolver
    return check_method()
  File "/Users/mac/.local/share/virtualenvs/clickandrap-0ABdElTc/lib/python3.6/site-packages/django/urls/resolvers.py", line 254, in check
    for pattern in self.url_patterns:
  File "/Users/mac/.local/share/virtualenvs/clickandrap-0ABdElTc/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/Users/mac/.local/share/virtualenvs/clickandrap-0ABdElTc/lib/python3.6/site-packages/django/urls/resolvers.py", line 405, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/Users/mac/.local/share/virtualenvs/clickandrap-0ABdElTc/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/Users/mac/.local/share/virtualenvs/clickandrap-0ABdElTc/lib/python3.6/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
    return import_module(self.urlconf_name)
  File "/Users/mac/.local/share/virtualenvs/clickandrap-0ABdElTc/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/mac/PycharmProjects/clickandrap/django_settings/urls.py", line 26, in <module>
    url(r'^transloadit/', include('transloadit_module.urls')),
  File "/Users/mac/.local/share/virtualenvs/clickandrap-0ABdElTc/lib/python3.6/site-packages/django/conf/urls/__init__.py", line50, in include
    urlconf_module = import_module(urlconf_module)
  File "/Users/mac/.local/share/virtualenvs/clickandrap-0ABdElTc/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/mac/PycharmProjects/clickandrap/transloadit_module/urls.py", line 3, in <module>
    from transloadit_module.views import *
  File "/Users/mac/PycharmProjects/clickandrap/transloadit_module/views.py", line 3, in <module>
    from transloadit import client
  File "/Users/mac/.local/share/virtualenvs/clickandrap-0ABdElTc/lib/python3.6/site-packages/transloadit/client.py", line 2, in <module>
    from . import assembly
  File "/Users/mac/.local/share/virtualenvs/clickandrap-0ABdElTc/lib/python3.6/site-packages/transloadit/assembly.py", line 4, in <module>
    from tusclient import client as tus
  File "/Users/mac/.local/share/virtualenvs/clickandrap-0ABdElTc/lib/python3.6/site-packages/tusclient/client.py", line 1, in <module>
    from tusclient.uploader import Uploader
  File "/Users/mac/.local/share/virtualenvs/clickandrap-0ABdElTc/lib/python3.6/site-packages/tusclient/uploader.py", line 11, in<module>
    from tusclient.request import TusRequest
  File "/Users/mac/.local/share/virtualenvs/clickandrap-0ABdElTc/lib/python3.6/site-packages/tusclient/request.py", line 1, in <module>
    import pycurl
ImportError: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (none/other)
@ifedapoolarewaju
Copy link
Collaborator

Hi @vmihalachi thank you for reporting this issue. This an error from one of the dependencies of tus-py-client, and it is new to me.

I found this useful workaround though(not sure if you might have tried it)

Basically execute the following steps:

  • pip uninstall pycurl
  • export PYCURL_SSL_LIBRARY=openssl
  • pip install pycurl

I'll work on a fix in the meantime.
Thank you for reporting and sorry for the inconvenience :)

@vmihalachi
Copy link
Author

Hi @ifedapoolarewaju, unfortunately on MacOS this seem to not work. Will try further.
Thank you for your work on the lib! 👍

@ifedapoolarewaju
Copy link
Collaborator

Hmm, that's weird, did you also try setting it to export PYCURL_SSL_LIBRARY=nss as some other answers indicated?

@vmihalachi
Copy link
Author

Okey, managed to fix the issue. I am using pipenv for the virtual enviroment https://docs.pipenv.org/.
What I did was:

Activating the virtual enviroment:

pipenv shell

Exporting two constants (as stated here pyca/cryptography#3489):

export CPPFLAGS=-I/usr/local/opt/openssl/include
export LDFLAGS=-L/usr/local/opt/openssl/lib

Installing with pip

pip install pycurl --global-option="--with-openssl"

Not sure that was the right way to fix the issue :)

@ifedapoolarewaju
Copy link
Collaborator

Apologies for the delay on this. I'll prioritize this some more and have a fix out for it soon. :)

@ifedapoolarewaju
Copy link
Collaborator

this issue is now fixed in v0.1.8

@hyukkyulee
Copy link

please try the following: https://cscheng.info/2018/01/26/installing-pycurl-on-macos-high-sierra.html

I went through similar problem when I upgraded my MAC OS to High-Sierra from El-Captain.

install homebrew by
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

and make sure you install openssl using homebrew
brew install openssl

@vmihalachi
Copy link
Author

@ifedapoolarewaju thanks!
@hyukkyulee I got this message when I did 'brew install openssl'

Warning: openssl 1.0.2n is already installed

@hyukkyulee
Copy link

@vmihalachi hey are you on high sierra?
if you already installed openssl,
try next steps which is uninstalling and properly installing pycurl

https://cscheng.info/2018/01/26/installing-pycurl-on-macos-high-sierra.html

@ifedapoolarewaju
Copy link
Collaborator

ifedapoolarewaju commented Mar 19, 2018

if you update to v0.1.8, there's no need to install pycurl anymore. The use of pycurl has been dropped, so the problem will no longer exist. Except you already have pycurl in your requirements.txt file, where you can simply delete it.

@vmihalachi
Copy link
Author

thanks to you both! 👍 :)

@daveblackb
Copy link

@hyukkyulee
Thanks for the cscheng link that works a treat for me

@zhangheli
Copy link

zhangheli commented Sep 3, 2018

use this with homebrew

pip install pycurl==7.43.0 --global-option=build_ext --global-option="-L/usr/local/opt/openssl/lib" --global-option="-I/usr/local/opt/openssl/include"

@avitko001c
Copy link

If anyone is having the issue of the opposite on MAC

libcurl link-time ssl backend (none/other) is different from compile-time ssl backend (openssl)

you will need to reinstall curl with brew using

brew reinstall curl --with-openssl

In order to have curl built with openssl and not the native Apple OS ssl. You may even see the following error during compile time of pycurl

ld: library not found for -lssl3

Once curl is reinstalled with openssl you can then use the above command from zhangheli to install pycurl. Make sure you follow the directions brew spits out for LD_LIBRARY and pkgconfig and the output for openssl

@yogeshkore
Copy link

yogeshkore commented Jan 9, 2019

Below worked for me:

pip uninstall pycurl
add below in /etc/bashrc
"
export PYCURL_SSL_LIBRARY=openssl
export PYCURL_SSL_LIBRARY=nss
export CPPFLAGS=-I/usr/local/opt/openssl/include
export LDFLAGS=-L/usr/local/opt/openssl/lib
"
logout , login and install as below
pip install pycurl==7.43.0 --global-option=build_ext --global-option="-L/usr/local/opt/openssl/lib" --global-option="-I/usr/local/opt/openssl/include"

@kavai77
Copy link

kavai77 commented Oct 24, 2019

brew reinstall curl --with-openssl

The Homebrew team has recently removed all install options for the cURL formula, which means you will not be able to do brew install curl --with-openssl now. Instead, do brew install curl-openssl. Make sure to uninstall the old one with brew uninstall curl first.
On MacOS Catalina this has worked for me:

export PYCURL_SSL_LIBRARY=openssl
export PYCURL_CURL_CONFIG=/usr/local/opt/curl-openssl/bin/curl-config;export LDFLAGS='-L/usr/local/opt/openssl/lib -L/usr/local/opt/c-ares/lib -L/usr/local/opt/nghttp2/lib -L/usr/local/opt/libmetalink/lib -L/usr/local/opt/rtmpdump/lib -L/usr/local/opt/libssh2/lib -L/usr/local/opt/openldap/lib -L/usr/local/opt/brotli/lib';export CPPFLAGS=-I/usr/local/opt/openssl/include;pip install pycurl --compile --no-cache-dir

@tashrifbillah
Copy link

Starting with @ifedapoolarewaju 's suggestion and by trial and error, the following worked for me:

pip uninstall pycurl
rm -rf ~/.cache/pip             # might not have any effect
yum -y install openssl          # might not have any effect
export PYCURL_SSL_LIBRARY=nss   # cursory step
pip install pycurl

@BlaShadow
Copy link

After a couple of searches these steps worked for me on centos:

pip uninstall pycurl
export PYCURL_SSL_LIBRARY=nss
pip install --compile pycurl

https://stackoverflow.com/questions/21487278/ssl-error-installing-pycurl-after-ssl-is-set

@michaelyousrie
Copy link

brew reinstall curl --with-openssl

The Homebrew team has recently removed all install options for the cURL formula, which means you will not be able to do brew install curl --with-openssl now. Instead, do brew install curl-openssl. Make sure to uninstall the old one with brew uninstall curl first. On MacOS Catalina this has worked for me:

export PYCURL_SSL_LIBRARY=openssl
export PYCURL_CURL_CONFIG=/usr/local/opt/curl-openssl/bin/curl-config;export LDFLAGS='-L/usr/local/opt/openssl/lib -L/usr/local/opt/c-ares/lib -L/usr/local/opt/nghttp2/lib -L/usr/local/opt/libmetalink/lib -L/usr/local/opt/rtmpdump/lib -L/usr/local/opt/libssh2/lib -L/usr/local/opt/openldap/lib -L/usr/local/opt/brotli/lib';export CPPFLAGS=-I/usr/local/opt/openssl/include;pip install pycurl --compile --no-cache-dir

for anyone coming in 2022+ for the same issue on mac.

I had the same issue for a while trying to get wfuzz to work. when I tried to import pycurl manually, I had the aforementioned error.

This is what solved it for me.

these commands are taken from the quoted reply above but edited the paths to include the libraries installed in homebrew's directory.

make sure all paths are valid on your machine and brew install [package] all the missing ones.

export PYCURL_CURL_CONFIG=/opt/homebrew/opt/curl/bin/curl-config;

export LDFLAGS='-L/opt/homebrew/opt/openssl@3/lib -L/opt/homebrew/opt/c-ares/lib -L/opt/homebrew/opt/nghttp2/lib -L/opt/homebrew/opt/libmetalink/lib -L/opt/homebrew/opt/rtmpdump/lib -L/opt/homebrew/opt/libssh2/lib -L/opt/homebrew/opt/openldap/lib -L/opt/homebrew/opt/brotli/lib';export CPPFLAGS=-I/opt/homebrew/opt/openssl@3/include;pip install pycurl --compile --no-cache-dir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests