Giter Site home page Giter Site logo

micropyramid / forex-python Goto Github PK

View Code? Open in Web Editor NEW
648.0 51.0 190.0 120 KB

Foreign exchange rates, Bitcoin price index and currency conversion using ratesapi.io

Home Page: http://forex-python.readthedocs.io/en/latest/usage.html

License: MIT License

Python 100.00%
python package bitcoin currency currency-exchange-rates currency-converter

forex-python's Introduction

forex-python

travis-ci coveralls Code Health pypi

Forex Python is a Free Foreign exchange rates and currency conversion.

Note: Install latest forex-python==1.6 to avoid RatesNotAvailableError

RunCode

Features of Forex Python:

  • List all currency rates.
  • BitCoin price for all currencies.
  • Converting amount to BitCoins.
  • Get historical rates for any day since 1999.
  • Conversion rate for one currency(ex; USD to INR).
  • Convert amount from one currency to other.('USD 10$' to INR).
  • Currency symbols.
  • Currency names.

Currency Source:

https://theforexapi.com is a free API for current and historical foreign exchange rates published by European Central Bank. The rates are updated daily 3PM CET.

BitCoin Price Source:

Bitcoin prices calculated every minute. For more information visit [CoinDesk](http://www.coindesk.com).

Installation

  • Install using python package

    pip install forex-python
    
            Or directly cloning the repo:
    
    python setup.py install

Usage Examples:

  • Initialize class

    python
    >>> from forex_python.converter import CurrencyRates
    >>> c = CurrencyRates()
  • list all latest currency rates for "USD"

    python
    >>> c.get_rates('USD')
    {u'IDR': 13625.0, u'BGN': 1.7433, u'ILS': 3.8794, u'GBP': 0.68641, u'DKK': 6.6289, u'CAD': 1.3106, u'JPY': 110.36, u'HUF': 282.36, u'RON': 4.0162, u'MYR': 4.081, u'SEK': 8.3419, u'SGD': 1.3815, u'HKD': 7.7673, u'AUD': 1.3833, u'CHF': 0.99144, u'KRW': 1187.3, u'CNY': 6.5475, u'TRY': 2.9839, u'HRK': 6.6731, u'NZD': 1.4777, u'THB': 35.73, u'EUR': 0.89135, u'NOK': 8.3212, u'RUB': 66.774, u'INR': 67.473, u'MXN': 18.41, u'CZK': 24.089, u'BRL': 3.5473, u'PLN': 3.94, u'PHP': 46.775, u'ZAR': 15.747}
  • Get conversion rate from USD to INR

    python
    >>> c.get_rate('USD', 'INR')
    67.473
  • Convert amount from USD to INR

    python
    >>> c.convert('USD', 'INR', 10)
    674.73
  • Force use of Decimal

    python
    >>> from forex_python.converter import CurrencyRates
    >>> c = CurrencyRates(force_decimal=True)
    >>> c.convert('USD', 'INR', Decimal('10.45'))
    705.09
    >>> c.convert('USD', 'INR', 10)
    DecimalFloatMismatchError: convert requires amount parameter is of type Decimal when use_decimal=True
  • Detect use of Decimal

    python
    >>> from forex_python.converter import CurrencyRates
    >>> c = CurrencyRates()
    >>> c.convert('USD', 'INR', Decimal('10.45'))
    705.09
    >>> c.convert('USD', 'INR', 10)
    674.73
  • Get latest Bitcoin price.

    python
    >>> from forex_python.bitcoin import BtcConverter
    >>> b = BtcConverter() # force_decimal=True to get Decimal rates
    >>> b.get_latest_price('USD')
    533.913
  • Convert Amount to Bitcoins based on latest exchange price.

    python
    >>> b.convert_to_btc(400, 'USD')
    0.7492699301118473
  • Get currency symbol using currency code

    python
    >>> from forex_python.converter import CurrencyCodes
    >>> c = CurrencyCodes()
    >>> print c.get_symbol('GBP')
    £

You can view the complete Documentation Here

Visit our Python Development page Here

We welcome your feedback and support, raise github ticket if you want to report a bug. Need new features? Contact us here

forex-python's People

Contributors

abhijeet-1110 avatar abhijit111093 avatar ajuska avatar ashwin31 avatar cedk avatar chaitu210 avatar filiplajszczak avatar internall avatar irajmishra avatar juliocesar126 avatar kunambi avatar mefuller avatar nikhila05 avatar robbie-palmer avatar sergey-scat avatar sposs avatar thefrog avatar timgates42 avatar timmygee avatar tmavre avatar vineeshan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

forex-python's Issues

forex_python down?

Getting the following error. Is the service down?
raise RatesNotAvailableError("Currency Rates Source Not Ready") forex_python.converter.RatesNotAvailableError: Currency Rates Source Not Ready

Currency Rates Source Not Ready

This error has been going on since 5 June 2018:

File \forex_python\converter.py , line 56, in get_rates
raise RatesNotAvailableError("Currency Rates Source Not Ready")
forex_python.converter.RatesNotAvailableError: Currency Rates Source Not Read

Currency Rates Source Not Ready

I am getting an exception: "forex_python.converter.RatesNotAvailableError: Currency Rates Source Not Ready". I checked the code, and basically, we are getting 404 while hitting http://api.fixer.io/latest.

Because of this, a non 200 code is generated and exception is getting raised.

ratesapi.io endpoint changed?

An Unexpected Error Has Occurred

HTTPSConnectionPool(host='ratesapi.io', port=443): Max retries exceeded with url: /api/latest?base=USD&symbols=EUR (Caused by NewConnectionError(': Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))

It looks like ratesapi.io should be updated to api.ratesapi.io.

Install under Python 3.6

On Arch 64bit using Python 3.6.2 I get the following error during pip (and manual installation after at git clone).

The problem is the README.rst file so there is a encoding issue in the file.

Emptying README.rst fixes the problem so python setup.py install works as intended.

Collecting forex-python
  Downloading forex-python-0.3.2.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-k7zj87sy/forex-python/setup.py", line 14, in <module>
        long_description="\n\n".join([open("README.rst").read()]),
      File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
        return codecs.ascii_decode(input, self.errors)[0]
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 3796: ordinal not in `range(128)

Add proxies or requests session to constructor

The constructor for CurrencyRates should have an optional argument of a requests session to be used for all API calls. This may speed up code that have a large number of API calls, and would allow users to specify proxy settings.

I'd mainly just want options to specify proxy settings and turn of SSL verification. Those could instead be optional arguments to the CurrencyRates constructor, without having to switch to requests sessions.

Having trouble in retriving information from api - may not be bug

I have a following issue, when I try to get currency rates :
Traceback (most recent call last):
File "<pyshell#4>", line 1, in
c.get_rates('USD')
File "C:\Python27\lib\site-packages\forex_python\converter.py", line 34, in get_rates
source_url = self._source_url() + date_str
File "C:\Python27\lib\site-packages\requests\api.py", line 70, in get
return request('get', url, params=params, **kwargs)
File "C:\Python27\lib\site-packages\requests\api.py", line 56, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 488, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "C:\Python27\lib\site-packages\requests\adapters.py", line 487, in send
raise ConnectionError(e, request=request)
ConnectionError: HTTPConnectionPool(host='api.fixer.io', port=80): Max retries exceeded with url: /latest?base=USD (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x03175790>: Failed to establish a new connection: [Errno 11004] getaddrinfo failed',))

I am using :
requests : https://github.com/kennethreitz/requests/releases/tag/v2.13.0
forex-python : https://github.com/MicroPyramid/forex-python/releases/tag/0.3.0

Is this project dead?

First, thanks to the contributors of this project for their work, which they have offered without asking for anything in return.

It seems that this project has not received updates in two years. Moreover, the API that it uses has been changed and I am not sure that the PRs fixing that are going to be reviewed and merged. @ashwin31, as the original developer, can you tell us is there are plans to continue the maintenance of this project? If the answer is negative, maybe someone would want to step up to maintain it (or a fork), or we can switch dependencies to another project if this is going to be abandoned.

Thanks for your time!

avoid api call on every function call

I am using the convert() on every single row in a csv file with 100 mi records.

Since the rate are updated 3PM daily, is there a plan to make a cache of the rate data into local storage, and just use it? or convert() function to take extra parameter of the rate object, then the software can call get_rate() and cache it

forex_python.converter.RatesNotAvailableError: Currency Rates Source Not Ready

from forex_python.converter import CurrencyRates
c = CurrencyRates()
c.get_rates('USD')
Traceback (most recent call last):
File "", line 1, in
File "/home/leo/miniconda3/envs/py3/lib/python3.6/site-packages/forex_python/converter.py", line 56, in get_rates
raise RatesNotAvailableError("Currency Rates Source Not Ready")

Hi, I found this problem occurred tonight. Is there any problem with the new api source?

Thank you.

Error

Traceback (most recent call last):
File "C:\Users\pooop\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connection.py", line 169, in _new_conn
conn = connection.create_connection(
File "C:\Users\pooop\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\util\connection.py", line 73, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "C:\Users\pooop\AppData\Local\Programs\Python\Python38-32\lib\socket.py", line 918, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11004] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\pooop\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 699, in urlopen
httplib_response = self._make_request(
File "C:\Users\pooop\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 382, in _make_request
self._validate_conn(conn)
File "C:\Users\pooop\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 1010, in _validate_conn
conn.connect()
File "C:\Users\pooop\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connection.py", line 353, in connect
conn = self._new_conn()
File "C:\Users\pooop\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connection.py", line 181, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x022C7388>: Failed to establish a new connection: [Errno 11004] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\pooop\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\adapters.py", line 439, in send
resp = conn.urlopen(
File "C:\Users\pooop\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "C:\Users\pooop\AppData\Local\Programs\Python\Python38-32\lib\site-packages\urllib3\util\retry.py", line 574, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.ratesapi.io', port=443): Max retries exceeded with url: /api/latest?base=USD&symbols=INR&rtype=fpy (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x022C7388>: Failed to establish a new connection: [Errno 11004] getaddrinfo failed'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\pooop\Desktop\Rock Paper Scissors\main.py", line 44, in
C.convert('USD','INR',1)
File "C:\Users\pooop\AppData\Local\Programs\Python\Python38-32\lib\site-packages\forex_python\converter.py", line 89, in convert
response = requests.get(source_url, params=payload)
File "C:\Users\pooop\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "C:\Users\pooop\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\pooop\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\pooop\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "C:\Users\pooop\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.ratesapi.io', port=443): Max retries exceeded with url: /api/latest?base=USD&symbols=INR&rtype=fpy (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x022C7388>: Failed to establish a new connection: [Errno 11004] getaddrinfo failed'))
that a error

Currency Rates Source Not Ready

Requirement already satisfied: forex-python in c:\python36\lib\site-packages (1.1)

File "C:\Python36\lib\site-packages\forex_python\converter.py", line 73, in get_rate
raise RatesNotAvailableError("Currency Rates Source Not Ready")
forex_python.converter.RatesNotAvailableError: Currency Rates Source Not Ready

Able to use this with Anaconda/iPython?

Hi,

I tried conda install forex-python but am getting an error message:
"package missing in current win-64 channels"

Is it possible to use this with Anaconda please? Thanks a lot!

identity get_rate

It would be nice that the conversion from one currency to itself also work

>>> c.get_rate("CHF", "CHF")
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/home/user/.virtualenvs/tool/local/lib/python2.7/site-packages/forex_python/converter.py", line 67, in get_rate
    base_cur, dest_cur, date_str))
RatesNotAvailableError: Currency Rate CHF => CHF not available for Date latest

Source not available

File "/usr/local/lib/python3.6/dist-packages/forex_python/converter.py", line 73, in get_rate
raise RatesNotAvailableError("Currency Rates Source Not Ready")
forex_python.converter.RatesNotAvailableError: Currency Rates Source Not Ready

Requirement already satisfied: forex-python in /usr/local/lib/python3.6/dist-packages (1.1)
Requirement already satisfied: requests in /usr/lib/python3/dist-packages (from forex-python) (2.20.0)
Requirement already satisfied: simplejson in /usr/local/lib/python3.6/dist-packages (from forex-python) (3.16.0)

No data past 12th June 2021 for USD to EUR pair

Currently using v1.6 :
When I run for dates before the 12th all is fine
get_rate('USD','EUR' , datetime.datetime.strptime('2021-06-11','%Y-%m-%d'))

0.8247422680412372

however when I try for 12th or later I get
get_rate('USD','EUR' , datetime.datetime.strptime('2021-06-12', '%Y-%m-%d'))

RatesNotAvailableError Traceback (most recent call last)
ipython-input-54-01a85e164fe5 in module
get_rate('USD','EUR' , datetime.datetime.strptime('2021-06-12', '%Y-%m-%d'))
~\AppData\Local\Continuum\anaconda3\lib\site-packages\forex_python\converter.py in get_rate(self, base_cur, dest_cur, date_obj)
77 base_cur, dest_cur, date_str))
78 return rate
79 raise RatesNotAvailableError("Currency Rates Source Not Ready")
80
81 def convert(self, base_cur, dest_cur, amount, date_obj=None):
RatesNotAvailableError: Currency Rates Source Not Ready

Currency Rates Source Not Ready

I am getting the following error
"forex_python.converter.RatesNotAvailableError: Currency Rates Source Not Ready"
My forex python is up to date.

is the api down

every request to the api comes back as 404. according to the status at io, the site is currently down
Screen Shot 2020-04-11 at 5 37 22 PM

Historic rates not available for several dates

For example https://ratesapi.io/api/2018-05-20?base=USD

Full list of dates not working in the last 365 days:
2018-06-05
2018-06-03
2018-06-02
2018-05-27
2018-05-26
2018-05-20
2018-05-19
2018-05-13
2018-05-12
2018-05-06
2018-05-05
2018-05-01
2018-04-29
2018-04-28
2018-04-22
2018-04-21
2018-04-15
2018-04-14
2018-04-08
2018-04-07
2018-04-02
2018-04-01
2018-03-31
2018-03-30
2018-03-25
2018-03-24
2018-03-18
2018-03-17
2018-03-11
2018-03-10
2018-03-04
2018-03-03
2018-02-25
2018-02-24
2018-02-18
2018-02-17
2018-02-11
2018-02-10
2018-02-04
2018-02-03
2018-01-28
2018-01-27
2018-01-21
2018-01-20
2018-01-14
2018-01-13
2018-01-07
2018-01-06
2018-01-01
2017-12-31
2017-12-30
2017-12-26
2017-12-25
2017-12-24
2017-12-23
2017-12-17
2017-12-16
2017-12-10
2017-12-09
2017-12-03
2017-12-02
2017-11-26
2017-11-25
2017-11-19
2017-11-18
2017-11-12
2017-11-11
2017-11-05
2017-11-04
2017-10-29
2017-10-28
2017-10-22
2017-10-21
2017-10-15
2017-10-14
2017-10-08
2017-10-07
2017-10-01
2017-09-30
2017-09-24
2017-09-23
2017-09-17
2017-09-16
2017-09-10
2017-09-09
2017-09-03
2017-09-02
2017-08-27
2017-08-26
2017-08-20
2017-08-19
2017-08-13
2017-08-12
2017-08-06
2017-08-05
2017-07-30
2017-07-29
2017-07-23
2017-07-22
2017-07-16
2017-07-15
2017-07-09
2017-07-08
2017-07-02
2017-07-01
2017-06-25
2017-06-24
2017-06-18
2017-06-17
2017-06-11
2017-06-10

Wrong historic exchange rates with EUR as base

I've tried to get historic exchange rates for EUR and USD. When using EUR as base currency there appeared sometimes unrealistic high values for USD. I couldn't find the bug in the code base but this is the code in python 2.7 I've been using:

import datetime
c = CurrencyRates(force_decimal=False)
d = datetime.datetime(2018, 5, 1, 18, 36, 28, 151012)
for t in range(100):
    try:
        ex_rate= c.get_rate('EUR', 'USD', (d - datetime.timedelta(days=t)))
        ex_rates = c.get_rates('EUR', (d - datetime.timedelta(days=t)))
        if ex_rate > 1.6:
            print ex_rate, ex_rates, d - datetime.timedelta(days=t)
    except Exception, e:
        print 'Exchange rate not available' 

When using USD as base rate this error didn't appear.

Translation into spanish

I'd like to translate this repo into spanish , it will help a lot of users that don't know english plus it also brings more people into the forex world , please do let me know if there's a procedure I've to follow

WRONG conversion Rate for GBP to INR

Hello Team,
inr=round(c.get_rate('GBP', 'INR',date),3)
For the above function since last three days getting same conversion rate
December 27, 2019 :: 92.306
December 26, 2019 :: 92.306
December 25, 2019 :: 92.306
December 24, 2019 :: 92.306

December 23, 2019 :: 92.11
December 22, 2019 :: 92.8
December 21, 2019 :: 92.8
this differs from actual conversion rates.

Can you please check once.

Thanks.

Currency Rates Source Not Ready

from forex_python.converter import CurrencyRates
c = CurrencyRates()
c.get_rates('USD')

raise RatesNotAvailableError("Currency Rates Source Not Ready")
forex_python.converter.RatesNotAvailableError: Currency Rates Source Not Ready

converter.py", line 32, in _get_date_string AttributeError: 'str' object has no attribute 'strftime'

when i run this
c.get_rates('USD','EUR')

I get this error

 File "forex.py", line 5, in <module>
    c.get_rates('USD','EUR')
  File "C:\site-packages\forex_python\converter.py", line 49, in get_rates
    date_str = self._get_date_string(date_obj)
  File "C:\site-packages\forex_python\converter.py", line 32, in _get_date_string
    date_str = date_obj.strftime('%Y-%m-%d')
AttributeError: 'str' object has no attribute 'strftime'

cannot install

pip install forex-python
Collecting forex-python
Using cached forex-python-0.3.2.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/private/var/folders/h1/nbbcsvp10jj11nqx1kf0j_6h0000gn/T/pip-build-jwkn3_qf/forex-python/setup.py", line 14, in
long_description="\n\n".join([open("README.rst").read()]),
File "/Users/razvan/dev/venv/bin/../lib/python3.5/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 3796: ordinal not in range(128)

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/h1/nbbcsvp10jj11nqx1kf0j_6h0000gn/T/pip-build-jwkn3_qf/forex-python/

(venv) $ pip --version
pip 9.0.1 from /Users/razvan/dev/venv/lib/python3.5/site-packages (python 3.5)
$ python --version
Python 3.5.2

$  uname -a
Darwin 15.6.0 Darwin Kernel Version 15.6.0: Tue Apr 11 16:00:51 PDT 2017; root:xnu-3248.60.11.5.3~1/RELEASE_X86_64 x86_64

EUR Currency is broken

EUR currency does not work properly. Convert from EUR to any other currency brings incorrect values at >1.
And converting from EUR to BTC <=1 also brings incorrect values.

Converting to same currency yields error

When I try to convert euro to euro I get an error

c.convert('EUR', 'EUR', 1)

Traceback (most recent call last):
  File "<ipython-input-166-826503d53e1f>", line 1, in <module>
    c.convert('eur', 'eur', 1)
  File "c:\python35\lib\site-packages\forex_python\converter.py", line 84, in convert
    source_url, dest_cur, date_str))
RatesNotAvailableError: Currency http://api.fixer.io/latest => eur rate not available for Date latest.

I'm not sure if this is intentional, but it would make my code cleaner if it just returned the same value.

Replace Bitcoin symbol with unicode

A bug has been introduced in 1.6

Experiencing an error when using c.get_symbol("EUR")

  File "/usr/local/lib/python3.8/site-packages/forex_python/converter.py", line 137, in get_symbol
    currency_dict = self._get_data(currency_code)
  File "/usr/local/lib/python3.8/site-packages/forex_python/converter.py", line 125, in _get_data
    currency_data = json.loads(f.read())
  File "/usr/local/lib/python3.8/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 1252: ordinal not in range(128)

Created a pull request, !94

pip install forex-python under Python 3.6.8 in failing on mac os x

Hi,
Today, I tried to install forex_python using pip, but failed:
Collecting forex_python
Requirement already satisfied: requests in /anaconda3/lib/python3.6/site-packages (from forex_python) (2.18.4)
Collecting dbus-python (from forex_python)
Using cached https://files.pythonhosted.org/packages/3f/e7/4edb582d1ffd5ac3c84188deea32e960b5c8c0fe1da56ce70224f85ce542/dbus-python-1.2.8.tar.gz
Requirement already satisfied: simplejson in /anaconda3/lib/python3.6/site-packages (from forex_python) (3.16.0)
Requirement already satisfied: notify2 in /anaconda3/lib/python3.6/site-packages (from forex_python) (0.3.1)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /anaconda3/lib/python3.6/site-packages (from requests->forex_python) (3.0.4)
Requirement already satisfied: idna<2.7,>=2.5 in /anaconda3/lib/python3.6/site-packages (from requests->forex_python) (2.6)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in /anaconda3/lib/python3.6/site-packages (from requests->forex_python) (1.22)
Requirement already satisfied: certifi>=2017.4.17 in /anaconda3/lib/python3.6/site-packages (from requests->forex_python) (2018.11.29)
Building wheels for collected packages: dbus-python
Building wheel for dbus-python (setup.py) ... error
Complete output from command /anaconda3/bin/python -u -c "import setuptools, tokenize;file='/private/var/folders/4l/phzz7lg162bdp43zvngkzf500000gn/T/pip-install-d528248k/dbus-python/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" bdist_wheel -d /private/var/folders/4l/phzz7lg162bdp43zvngkzf500000gn/T/pip-wheel-3s_dwtm4 --python-tag cp36:
running bdist_wheel
running build
creating /private/var/folders/4l/phzz7lg162bdp43zvngkzf500000gn/T/pip-install-d528248k/dbus-python/build
creating /private/var/folders/4l/phzz7lg162bdp43zvngkzf500000gn/T/pip-install-d528248k/dbus-python/build/temp.macosx-10.7-x86_64-3.6
checking whether make supports nested variables... no
checking whether to enable maintainer-specific portions of Makefiles... no
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in /private/var/folders/4l/phzz7lg162bdp43zvngkzf500000gn/T/pip-install-d528248k/dbus-python/build/temp.macosx-10.7-x86_64-3.6': configure: error: C compiler cannot create executables See config.log' for more details
Traceback (most recent call last):
File "", line 1, in
File "/private/var/folders/4l/phzz7lg162bdp43zvngkzf500000gn/T/pip-install-d528248k/dbus-python/setup.py", line 109, in
tests_require=['tap.py'],
File "/anaconda3/lib/python3.6/site-packages/setuptools/init.py", line 145, in setup
return distutils.core.setup(**attrs)
File "/anaconda3/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/anaconda3/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/anaconda3/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/anaconda3/lib/python3.6/site-packages/wheel/bdist_wheel.py", line 188, in run
self.run_command('build')
File "/anaconda3/lib/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/anaconda3/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/private/var/folders/4l/phzz7lg162bdp43zvngkzf500000gn/T/pip-install-d528248k/dbus-python/setup.py", line 62, in run
cwd=builddir)
File "/anaconda3/lib/python3.6/subprocess.py", line 311, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/private/var/folders/4l/phzz7lg162bdp43zvngkzf500000gn/T/pip-install-d528248k/dbus-python/configure', '--disable-maintainer-mode', 'PYTHON=/anaconda3/bin/python', '--prefix=/private/var/folders/4l/phzz7lg162bdp43zvngkzf500000gn/T/pip-install-d528248k/dbus-python/build/temp.macosx-10.7-x86_64-3.6/prefix']' returned non-zero exit status 77.


Failed building wheel for dbus-python
Running setup.py clean for dbus-python
Failed to build dbus-python
Installing collected packages: dbus-python, forex-python
Running setup.py install for dbus-python ... error
Complete output from command /anaconda3/bin/python -u -c "import setuptools, tokenize;file='/private/var/folders/4l/phzz7lg162bdp43zvngkzf500000gn/T/pip-install-d528248k/dbus-python/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /private/var/folders/4l/phzz7lg162bdp43zvngkzf500000gn/T/pip-record-17_xhgd1/install-record.txt --single-version-externally-managed --compile:
running install
running build
creating /private/var/folders/4l/phzz7lg162bdp43zvngkzf500000gn/T/pip-install-d528248k/dbus-python/build
creating /private/var/folders/4l/phzz7lg162bdp43zvngkzf500000gn/T/pip-install-d528248k/dbus-python/build/temp.macosx-10.7-x86_64-3.6
checking whether make supports nested variables... no
checking whether to enable maintainer-specific portions of Makefiles... no
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in /private/var/folders/4l/phzz7lg162bdp43zvngkzf500000gn/T/pip-install-d528248k/dbus-python/build/temp.macosx-10.7-x86_64-3.6': configure: error: C compiler cannot create executables See config.log' for more details
Traceback (most recent call last):
File "", line 1, in
File "/private/var/folders/4l/phzz7lg162bdp43zvngkzf500000gn/T/pip-install-d528248k/dbus-python/setup.py", line 109, in
tests_require=['tap.py'],
File "/anaconda3/lib/python3.6/site-packages/setuptools/init.py", line 145, in setup
return distutils.core.setup(**attrs)
File "/anaconda3/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/anaconda3/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/anaconda3/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/anaconda3/lib/python3.6/site-packages/setuptools/command/install.py", line 61, in run
return orig.install.run(self)
File "/anaconda3/lib/python3.6/distutils/command/install.py", line 545, in run
self.run_command('build')
File "/anaconda3/lib/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/anaconda3/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/private/var/folders/4l/phzz7lg162bdp43zvngkzf500000gn/T/pip-install-d528248k/dbus-python/setup.py", line 62, in run
cwd=builddir)
File "/anaconda3/lib/python3.6/subprocess.py", line 311, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/private/var/folders/4l/phzz7lg162bdp43zvngkzf500000gn/T/pip-install-d528248k/dbus-python/configure', '--disable-maintainer-mode', 'PYTHON=/anaconda3/bin/python', '--prefix=/private/var/folders/4l/phzz7lg162bdp43zvngkzf500000gn/T/pip-install-d528248k/dbus-python/build/temp.macosx-10.7-x86_64-3.6/prefix']' returned non-zero exit status 77.

----------------------------------------

Command "/anaconda3/bin/python -u -c "import setuptools, tokenize;file='/private/var/folders/4l/phzz7lg162bdp43zvngkzf500000gn/T/pip-install-d528248k/dbus-python/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /private/var/folders/4l/phzz7lg162bdp43zvngkzf500000gn/T/pip-record-17_xhgd1/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/4l/phzz7lg162bdp43zvngkzf500000gn/T/pip-install-d528248k/dbus-python/

Please help, thanks.

Allow installation without dbus

Noticed, that 1.2 added a CLI interface which uses dbus-python.

Unfortunately since dbus-python is a requirement, this means, that dbus-python will be installed besides forex-python even if notification support or the cli interface is not needed.

This is problematic, because dbus-python needs C-Extension and therefore C compiler and Python development headers installed. That's nothing you want to install e.g. on a server or in a docker environment for no reason. Or have as a requirement for a application, which uses your library as backend - for no other reason.

So my question: Is there any way or would it possible to add a way to install forex-python without dbus-python?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.