pusher / pusher-http-python

Pusher Channels HTTP API library for Python
https://pusher.com/docs/server_api_guide
MIT License
376 stars 113 forks source link

Error installing pusher with pip in debian 8 with python 2.7.9 #91

Closed hackerunet closed 6 years ago

hackerunet commented 7 years ago

Hello, I have issues installing pusher with pip, when I did pip install pusher I got this:

Requirement already satisfied (use --upgrade to upgrade): pusher in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied (use --upgrade to upgrade): six in /usr/lib/python2.7/dist-packages (from pusher)
Requirement already satisfied (use --upgrade to upgrade): requests>=2.3.0 in /usr/lib/python2.7/dist-packages (from pusher)
Requirement already satisfied (use --upgrade to upgrade): urllib3==1.17 in /usr/local/lib/python2.7/dist-packages (from pusher)
Requirement already satisfied (use --upgrade to upgrade): pyopenssl in /usr/lib/python2.7/dist-packages (from pusher)
Requirement already satisfied (use --upgrade to upgrade): ndg-httpsclient in /usr/lib/pymodules/python2.7 (from pusher)
Requirement already satisfied (use --upgrade to upgrade): pyasn1 in /usr/lib/python2.7/dist-packages (from pusher)
Requirement already satisfied (use --upgrade to upgrade): cryptography>=0.2.1 in /usr/lib/python2.7/dist-packages (from pyopenssl->pusher)
Requirement already satisfied (use --upgrade to upgrade): cffi>=0.8 in /usr/lib/python2.7/dist-packages (from cryptography>=0.2.1->pyopenssl->pusher)
Requirement already satisfied (use --upgrade to upgrade): pycparser in /usr/lib/python2.7/dist-packages (from cffi>=0.8->cryptography>=0.2.1->pyopenssl->pusher)
Cleaning up...

And when I try to use it I got this error:

Traceback (most recent call last):
  File "scripts/notif_alarmas.py", line 73, in <module>
    notif_alarmas().getAlarms()
  File "scripts/notif_alarmas.py", line 37, in getAlarms
    pusher = Pusher(app_id=self.push_id, key=self.push_key, secret=self.push_secret)
  File "/usr/local/lib/python2.7/dist-packages/pusher/pusher.py", line 52, in __init__
    json_encoder, json_decoder, backend, **backend_options)
  File "/usr/local/lib/python2.7/dist-packages/pusher/pusher_client.py", line 34, in __init__
    json_encoder, json_decoder, backend, **backend_options)
  File "/usr/local/lib/python2.7/dist-packages/pusher/client.py", line 20, in __init__
    from .requests import RequestsBackend
  File "/usr/local/lib/python2.7/dist-packages/pusher/requests.py", line 17, in <module>
    import urllib3.contrib.pyopenssl
  File "/usr/local/lib/python2.7/dist-packages/urllib3/contrib/pyopenssl.py", line 48, in <module>
    from cryptography import x509
ImportError: cannot import name x509

After seeing this I try easy_install cryptography and it installed more packages but then when I run the program again I got this:

Using /usr/lib/python2.7/dist-packages
Processing dependencies for cryptography
Finished processing dependencies for cryptography
root@servertrack:/var/www/axiomatracker# python scripts/notif_alarmas.py
Traceback (most recent call last):
  File "scripts/notif_alarmas.py", line 73, in <module>
    notif_alarmas().getAlarms()
  File "scripts/notif_alarmas.py", line 43, in getAlarms
    pusher.trigger(u["ws_channel"], 'alarms_event', {'message': message})
  File "/usr/local/lib/python2.7/dist-packages/pusher/pusher.py", line 117, in trigger
    channels, event_name, data, socket_id)
  File "/usr/local/lib/python2.7/dist-packages/pusher/http.py", line 31, in __call__
    return self.client.http.send_request(self.make_request(*args, **kwargs))
  File "/usr/local/lib/python2.7/dist-packages/pusher/requests.py", line 44, in send_request
    **self.options)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 457, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 569, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 362, in send
    timeout=timeout
  File "/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py", line 516, in urlopen
    body=body, headers=headers)
  File "/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py", line 304, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python2.7/dist-packages/urllib3/connectionpool.py", line 724, in _validate_conn
    conn.connect()
  File "/usr/lib/python2.7/dist-packages/urllib3/connection.py", line 237, in connect
    ssl_version=resolved_ssl_version)
  File "/usr/lib/python2.7/dist-packages/urllib3/contrib/pyopenssl.py", line 263, in ssl_wrap_socket
    ctx.load_verify_locations(ca_certs, None)
  File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 303, in load_verify_locations
    raise TypeError("cafile must be None or a byte string")
TypeError: cafile must be None or a byte string

Please help.

hackerunet commented 7 years ago

This is the last error I found on pip.log after uninstalling all packages and trying to reinstall pusher only.

Cleaning up...
Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 290, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1091, in prepare_files
    req_to_install.check_if_exists()
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 815, in check_if_exists
    existing_dist = pkg_resources.get_distribution(self.req.project_name)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 349, in get_distribution
    dist = get_provider(dist)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 229, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 745, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 644, in resolve
    raise VersionConflict(dist, req)
VersionConflict: (urllib3 1.9.1 (/usr/lib/python2.7/dist-packages), Requirement.parse('urllib3==1.17'))

I have uninstalled everything and reinstalled and I got back to the previous error:

File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 303, in load_verify_locations
    raise TypeError("cafile must be None or a byte string")
TypeError: cafile must be None or a byte string
callum-oakley commented 7 years ago

This looks like it could be related to #67? Do you have any luck trying different versions of pyopenssl?

silver2row commented 7 years ago

Hello...

See here: sudo apt-get install build-essential libssl-dev libffi-dev python-dev

Use those dependencies. That should do the trick. Debian does not come with them already installed.

Seth

WillSewell commented 6 years ago

I've added a note to install OpenSSL on linux in https://github.com/pusher/pusher-http-python/commit/069d112056f1581f0b7c804aead746119d807380