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

gbk python readwrite #281

Closed
willshion opened this issue Oct 5, 2019 · 7 comments
Closed

gbk python readwrite #281

willshion opened this issue Oct 5, 2019 · 7 comments
Labels
bug

Comments

@willshion
Copy link

@willshion willshion commented Oct 5, 2019

UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 205: illegal multibyte sequence"

when tpye streamlit hello

@willshion willshion added the bug label Oct 5, 2019
@willshion

This comment has been minimized.

Copy link
Author

@willshion willshion commented Oct 5, 2019

maybe solution
解决办法1.

  

FILE_OBJECT= open('order.log','r', encoding='UTF-8')
解决办法2.

  

FILE_OBJECT= open('order.log','rb')

@willshion

This comment has been minimized.

Copy link
Author

@willshion willshion commented Oct 5, 2019

maybe iam py3.5

@tvst

This comment has been minimized.

Copy link
Collaborator

@tvst tvst commented Oct 5, 2019

Hi @willshion , thanks for the bug report.

I have a hypothesis on what could be causing this bug. Can you try running the 3 code snippets below on a Python console and then let me know if there are any errors? This will let me know if my hypothesis is correct 😃

  1. First test:
import pandas as pd
import os
pd.read_json(os.path.join(
    "https://raw.githubusercontent.com/streamlit/streamlit/develop/examples/",
    "data", "bike_rental_stats.json"))
  1. Second test:
import pandas as pd
pd.read_json(
    "https://raw.githubusercontent.com/streamlit/streamlit/"
    "develop/examples/data/bike_rental_stats.json")
  1. Third test:
import pandas as pd
pd.read_json(
    "https://raw.githubusercontent.com/streamlit/streamlit/"
    "develop/examples/data/bike_rental_stats.json", encoding='utf-8')

Thanks!

@Vopaaz

This comment has been minimized.

Copy link

@Vopaaz Vopaaz commented Oct 7, 2019

Hi @tvst, I am having a similar issue. The exception I get is

'gbk' codec can't decode byte 0x94 in position 9229: illegal multibyte sequence

I am in Streamlit, version 0.47.4, Python 3.7.2, Windows 10.


Here is the result of the three code snippets you provide:

>>> import pandas as pd
>>> import os
>>> pd.read_json(os.path.join(
...     "https://raw.githubusercontent.com/streamlit/streamlit/develop/examples/",
...     "data", "bike_rental_stats.json"))
Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
  File "C:\Users\Vopaaz\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\io\json\json.py", line 413, in read_json
    path_or_buf, encoding=encoding, compression=compression,
  File "C:\Users\Vopaaz\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\io\common.py", line 202, in get_filepath_or_buffer
    req = _urlopen(filepath_or_buffer)
  File "C:\Users\Vopaaz\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Users\Vopaaz\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 531, in open
    response = meth(req, response)
  File "C:\Users\Vopaaz\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Users\Vopaaz\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 569, in error
    return self._call_chain(*args)
  File "C:\Users\Vopaaz\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 503, in _call_chain
    result = func(*args)
  File "C:\Users\Vopaaz\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found
>>> import pandas as pd
>>> pd.read_json(
...     "https://raw.githubusercontent.com/streamlit/streamlit/"
...     "develop/examples/data/bike_rental_stats.json")
                         address        lat         lon  racks  spaces
0                   939 ELLIS ST  37.783466 -122.421778      2       4
1                 1380 HOWARD ST  37.774458 -122.414411      1       2
2                    1195 OAK ST  37.772737 -122.438887      1       2
3               1387 VALENCIA ST  37.750874 -122.420200      1       2
4                180 TOWNSEND ST  37.779369 -122.392606      1       2
5                247 FILLMORE ST  37.771850 -122.430660      1       2
6                247 FILLMORE ST  37.771850 -122.430660      1       2
7                2690 MISSION ST  37.754029 -122.418974      2       4
8              400 MCALLISTER ST  37.780519 -122.419014      7      14
9                    680 08TH ST  37.770128 -122.404719      1       2
10               101 TOWNSEND ST  37.780226 -122.390466      1       2
11                1186 FOLSOM ST  37.775470 -122.409866      1       2
12               1301 SANSOME ST  37.802327 -122.403298      1       2
13              1304 VALENCIA ST  37.751851 -122.420935      1       2
14              1380 VALENCIA ST  37.750802 -122.420834      1       2
15                1601 HOWARD ST  37.771394 -122.416789      2       4
16               1700 FILBERT ST  37.799281 -122.427674      1       2
17                1700 OCEAN AVE  37.724988 -122.460192      1       2
18               201 GUERRERO ST  37.767853 -122.424167      2       4
19                  2500 16TH ST  37.765820 -122.411968      1       2
20                  2525 16TH ST  37.765121 -122.411897      1       2
21                  300 GOUGH ST  37.776104 -122.422666      1       2
22                  3232 16TH ST  37.764990 -122.424904      1       2
23             425 DIVISADERO ST  37.773364 -122.437875      1       2
24                426 BRANNAN ST  37.779654 -122.395232      1       2
25               499 GUERRERO ST  37.763298 -122.423730      1       2
26                501 DOLORES ST  37.761320 -122.425711      2       4
27               647 VALENCIA ST  37.762535 -122.421450      1       2
28                 762 FULTON ST  37.778282 -122.429259      1       2
29    1 DR CARLTON B GOODLETT PL  37.778846 -122.419030      2       4
...                          ...        ...         ...    ...     ...
2490             584 VALENCIA ST  37.763612 -122.422059      1       2
2491             598 VALENCIA ST  37.763448 -122.422043      1       2
2492               600 MARKET ST  37.788779 -122.402575      2       4
2493               603 HAIGHT ST  37.771646 -122.432216      1       2
2494               607 HAIGHT ST  37.771634 -122.432311      1       2
2495             630 VALENCIA ST  37.762848 -122.422005      6      12
2496                 646 CLAY ST  37.794582 -122.404007      1       2
2497           661 DIVISADERO ST  37.775744 -122.438287      1       2
2498                 668 CLAY ST  37.794741 -122.404269      1       2
2499                 670 04TH ST  37.777233 -122.395578      2       4
2500              672 STANYAN ST  37.769707 -122.453327      1       2
2501              685 CHENERY ST  37.734350 -122.433618      1       2
2502              688 MISSION ST  37.786724 -122.401815      1       2
2503            688 SAN JOSE AVE  37.744182 -122.422896      1       2
2504             699 VALENCIA ST  37.761839 -122.421482      1       2
2505              700 MISSION ST  37.786206 -122.402532      1       2
2506               733 KEARNY ST  37.794835 -122.405351     13      26
2507              735 VALLEJO ST  37.798305 -122.409527     10      20
2508              746 CLEMENT ST  37.783071 -122.467376      1       2
2509             762 VALENCIA ST  37.760753 -122.421787      1       2
2510             766 VALENCIA ST  37.760649 -122.421795      5      10
2511             777 VALENCIA ST  37.760565 -122.421188      9      18
2512               870 MARKET ST  37.785111 -122.407423      1       2
2513                 888 TURK ST  37.781878 -122.423645      1       2
2514           9 WEST PORTAL AVE  37.740587 -122.465765      1       2
2515             900 VALENCIA ST  37.758255 -122.421520      1       2
2516                91 WALTER ST  37.767817 -122.432136      1       2
2517                  916 KEARNY  37.796535 -122.405021      1       2
2518                 939 EDDY ST  37.782316 -122.423112      1       2
2519               945 MARKET ST  37.782887 -122.408778      1       2

[2520 rows x 5 columns]
>>> import pandas as pd
>>> pd.read_json(
...     "https://raw.githubusercontent.com/streamlit/streamlit/"
...     "develop/examples/data/bike_rental_stats.json", encoding='utf-8')
                         address        lat         lon  racks  spaces
0                   939 ELLIS ST  37.783466 -122.421778      2       4
1                 1380 HOWARD ST  37.774458 -122.414411      1       2
2                    1195 OAK ST  37.772737 -122.438887      1       2
3               1387 VALENCIA ST  37.750874 -122.420200      1       2
4                180 TOWNSEND ST  37.779369 -122.392606      1       2
5                247 FILLMORE ST  37.771850 -122.430660      1       2
6                247 FILLMORE ST  37.771850 -122.430660      1       2
7                2690 MISSION ST  37.754029 -122.418974      2       4
8              400 MCALLISTER ST  37.780519 -122.419014      7      14
9                    680 08TH ST  37.770128 -122.404719      1       2
10               101 TOWNSEND ST  37.780226 -122.390466      1       2
11                1186 FOLSOM ST  37.775470 -122.409866      1       2
12               1301 SANSOME ST  37.802327 -122.403298      1       2
13              1304 VALENCIA ST  37.751851 -122.420935      1       2
14              1380 VALENCIA ST  37.750802 -122.420834      1       2
15                1601 HOWARD ST  37.771394 -122.416789      2       4
16               1700 FILBERT ST  37.799281 -122.427674      1       2
17                1700 OCEAN AVE  37.724988 -122.460192      1       2
18               201 GUERRERO ST  37.767853 -122.424167      2       4
19                  2500 16TH ST  37.765820 -122.411968      1       2
20                  2525 16TH ST  37.765121 -122.411897      1       2
21                  300 GOUGH ST  37.776104 -122.422666      1       2
22                  3232 16TH ST  37.764990 -122.424904      1       2
23             425 DIVISADERO ST  37.773364 -122.437875      1       2
24                426 BRANNAN ST  37.779654 -122.395232      1       2
25               499 GUERRERO ST  37.763298 -122.423730      1       2
26                501 DOLORES ST  37.761320 -122.425711      2       4
27               647 VALENCIA ST  37.762535 -122.421450      1       2
28                 762 FULTON ST  37.778282 -122.429259      1       2
29    1 DR CARLTON B GOODLETT PL  37.778846 -122.419030      2       4
...                          ...        ...         ...    ...     ...
2490             584 VALENCIA ST  37.763612 -122.422059      1       2
2491             598 VALENCIA ST  37.763448 -122.422043      1       2
2492               600 MARKET ST  37.788779 -122.402575      2       4
2493               603 HAIGHT ST  37.771646 -122.432216      1       2
2494               607 HAIGHT ST  37.771634 -122.432311      1       2
2495             630 VALENCIA ST  37.762848 -122.422005      6      12
2496                 646 CLAY ST  37.794582 -122.404007      1       2
2497           661 DIVISADERO ST  37.775744 -122.438287      1       2
2498                 668 CLAY ST  37.794741 -122.404269      1       2
2499                 670 04TH ST  37.777233 -122.395578      2       4
2500              672 STANYAN ST  37.769707 -122.453327      1       2
2501              685 CHENERY ST  37.734350 -122.433618      1       2
2502              688 MISSION ST  37.786724 -122.401815      1       2
2503            688 SAN JOSE AVE  37.744182 -122.422896      1       2
2504             699 VALENCIA ST  37.761839 -122.421482      1       2
2505              700 MISSION ST  37.786206 -122.402532      1       2
2506               733 KEARNY ST  37.794835 -122.405351     13      26
2507              735 VALLEJO ST  37.798305 -122.409527     10      20
2508              746 CLEMENT ST  37.783071 -122.467376      1       2
2509             762 VALENCIA ST  37.760753 -122.421787      1       2
2510             766 VALENCIA ST  37.760649 -122.421795      5      10
2511             777 VALENCIA ST  37.760565 -122.421188      9      18
2512               870 MARKET ST  37.785111 -122.407423      1       2
2513                 888 TURK ST  37.781878 -122.423645      1       2
2514           9 WEST PORTAL AVE  37.740587 -122.465765      1       2
2515             900 VALENCIA ST  37.758255 -122.421520      1       2
2516                91 WALTER ST  37.767817 -122.432136      1       2
2517                  916 KEARNY  37.796535 -122.405021      1       2
2518                 939 EDDY ST  37.782316 -122.423112      1       2
2519               945 MARKET ST  37.782887 -122.408778      1       2

[2520 rows x 5 columns]

Hopefully, this could help!

@GoooIce

This comment has been minimized.

Copy link

@GoooIce GoooIce commented Oct 11, 2019

same error

Skipping PyPI version check
Setting up signal handler
Using selector: SelectSelector
Server state: None -> State.INITIAL
Creating new context for ws PREHEATED_REPORT_SESSION
No singleton. Registering one.
Watcher created for C:\Users\goooice\Documents\GitHub\prodigy-recipes\streamlit\streamlit_prodigy.py
ReportSession initialized (id=0)
Beginning script thread
Starting server...
Running script RerunData(widget_state=None)
Serving static content from c:\users\goooice\anaconda3\envs\ml\lib\site-packages\streamlit\static
OnScriptRunnerEvent: ScriptRunnerEvent.SCRIPT_STARTED
Server started on port 8501
Server state: State.INITIAL -> State.WAITING_FOR_FIRST_BROWSER
New browser connection: gather_usage_stats=True, sharing_enabled=False, max_cached_message_age=2

Fatal script error: 'gbk' codec can't decode byte 0x85 in position 5853: illegal multibyte sequence
OnScriptRunnerEvent: ScriptRunnerEvent.SCRIPT_STOPPED_WITH_COMPILE_ERROR

but, when run the example:
`import streamlit as st

x = st.slider('Select a value')
st.write(x, 'squared is', x * x)`

streamlit run example.py

is ok...

@mengyou658

This comment has been minimized.

Copy link

@mengyou658 mengyou658 commented Oct 11, 2019

when i delete all chinese chars ,it run ok

@tvst

This comment has been minimized.

Copy link
Collaborator

@tvst tvst commented Oct 14, 2019

Based on @Vopaaz's debug info I think the latest Streamlit (version 0.48.1) fixes this.

So I'm closing this bug. But please reopen if you're still experiencing it in 0.48.1 or newer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.