ericsomdahl / python-bittrex

Python bindings for bittrex
MIT License
585 stars 283 forks source link

Python3.5? #78

Closed JeffWScott closed 6 years ago

JeffWScott commented 7 years ago

Does this work in python3? I have it running great in python2.7 but i want to take advantage of async with python3.

I get this error when trying to do a simple get_market_summaries()

Traceback (most recent call last): File "orderBook.py", line 33, in order = my_bittrex.get_market_summaries() File "/usr/local/lib/python3.5/dist-packages/bittrex/bittrex.py", line 110, in get_market_summaries return self.api_query('getmarketsummaries') File "/usr/local/lib/python3.5/dist-packages/bittrex/bittrex.py", line 62, in api_query request_url += urllib.urlencode(options) AttributeError: module 'urllib' has no attribute 'urlencode'

TalhaAsmal commented 7 years ago

Hi @JeffWScott

Are you using the latest source code? Python3 compatibility was fixed in https://github.com/ericsomdahl/python-bittrex/commit/066f5096c252f3c97c5753e015bbb5f7835fa021 which was pushed a year ago.

Please try pulling the latest code and try again.

JeffWScott commented 7 years ago

I installed through pip. Is that my problem? I have python2.7 and python3 installed. Is there something different I have to do to install this via the setup.py instead of python3 -m pip install ??

TalhaAsmal commented 7 years ago

The pip package is quite old, so that is most likely the problem.

You can clone this repo from github, then navigate to the directory where the repo is cloned and install via the setup.py:

cd ~
git clone https://github.com/ericsomdahl/python-bittrex.git
cd python-bittrex
python3 setup.py install

If you want to install globally, replace the last line with: sudo python3 setup.py install

If you want to use pip, you can do: pip install --upgrade git+https://github.com/ericsomdahl/python-bittrex.git

treethought commented 7 years ago

If you haven't solved this, the problem may be that the package is only installed for your python 2 installation. If that's the case, you should be able to install for python 3 with pip3 install ...

JeffWScott commented 6 years ago

Dammit. I finally got around to running the commands supplied by @TalhaAsmal and now I cannot run any scripts. I get:

Traceback (most recent call last): File "databaseLoader.py", line 11, in from bittrex import Bittrex

I created a script to view my pip packages and I see python-bittrex2.0.

['dnspython==1.12.0', 'pip==9.0.1', 'pushbullet.py==0.11.0', 'pycrypto==2.6.1', 'pycurl==7.43.0', 'pymongo==3.5.1', 'python-apt==1.1.0b1', 'python-bittrex==0.2.0', 'python-magic==0.4.13', 'requests==2.7.0', 'setuptools==20.7.0', 'six==1.11.0', 'websocket-client==0.44.0', 'wheel==0.29.0']

Any ideas?

JeffWScott commented 6 years ago

I think I found the issue.. although i have no idea how to solve it.

when I install things they end up in /usr/local/lib/python2.7 (or 3.5)

when I run this command: python -c "from distutils.sysconfig import *; print(get_python_lib())"

I get /usr/lib/python2.7/dist-packages

bittrex is not installed there.

it is installed in: /usr/local/lib/python2.7 ~/.local/lib/python2.7

how do I get it to install into that other directory? Or how do I sort this mess out?

Thanks.

TalhaAsmal commented 6 years ago

Try to import bittrex this way:

from bittrex.bittrex import Bittrex

JeffWScott commented 6 years ago

That worked! Can you explain why? (and maybe update the readme?) I was literally 2 seconds away from redoing my whole dev box from scratch when I thought, you know what, I'll see if Tal responded.

gcarq commented 6 years ago

@JeffWScott That is because the bittrex module has an empty __init__.py file. To fix this the __init__.py should look like this:

from . import bittrex
TalhaAsmal commented 6 years ago

There's actually a pull request to fix the import issue, but it hasn't been merged yet

TalhaAsmal commented 6 years ago

This has been resolved