MaxHalford / sorobn

🧮 Bayesian networks in Python
https://sorobn.streamlit.app
MIT License
234 stars 34 forks source link

Installation failing on Windows due to encoding issue #18

Closed George713 closed 3 years ago

George713 commented 3 years ago

Hi Max,

sweet library! What a breeze it is to use pandas with a Bayesian network!

I stumbled upon an installation issue, that's easy to fix:

Problem

When installing hedgehog on Windows via $ pip install git+https://github.com/MaxHalford/hedgehog this error occurs:

Collecting git+https://github.com/MaxHalford/hedgehog
  Cloning https://github.com/MaxHalford/hedgehog to c:\users\u870378\appdata\local\temp\pip-req-build-1zcx1moe
  Running command git clone -q https://github.com/MaxHalford/hedgehog 'C:\Users\u870378\AppData\Local\Temp\pip-req-build-1zcx1moe'
    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\u870378\AppData\Local\pypoetry\Cache\virtualenvs\ki-servicekompass-5UQ9rpz6-py3.9\Scripts\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\u870378\\AppData\\Local\\Tem
p\\pip-req-build-1zcx1moe\\setup.py'"'"'; __file__='"'"'C:\\Users\\u870378\\AppData\\Local\\Temp\\pip-req-build-1zcx1moe\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'
"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\u870378\AppData\Local\Temp\pip-pip-egg-info-a3nzzdf8'
         cwd: C:\Users\u870378\AppData\Local\Temp\pip-req-build-1zcx1moe\
    Complete output (9 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\u870378\AppData\Local\Temp\pip-req-build-1zcx1moe\setup.py", line 16, in <module>
        long_description=read('README.md'),
      File "C:\Users\u870378\AppData\Local\Temp\pip-req-build-1zcx1moe\setup.py", line 6, in read
        return open(os.path.join(os.path.dirname(__file__), fname)).read()
      File "C:\Program Files\Python39\lib\encodings\cp1252.py", line 23, in decode
        return codecs.charmap_decode(input,self.errors,decoding_table)[0]
    UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 1856: character maps to <undefined>
    ----------------------------------------
WARNING: Discarding git+https://github.com/MaxHalford/hedgehog. Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Explanation / Solution

This error is caused by Windows' default encoding cp1252. For using utf-8 across platforms, setup.py can be adjusted in line 6:

    return open(os.path.join(os.path.dirname(__file__), fname), encoding="utf-8").read()

Solution was tested on Windows. No change should be noticed on unix systems.

Source: https://stackoverflow.com/questions/49640513/unicodedecodeerror-charmap-codec-cant-decode-byte-0x9d-in-position-x-charac/49642852

Cheers

MaxHalford commented 3 years ago

Hello @George713, thanks for the kind words!

Thanks for taking the time to open this issue. I've just pushed the fix you propose. Let me know if the problem persists.

Kind regards.

George713 commented 3 years ago

Works like a charm! Closing.