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

pip install的时候提示字符编码错误 #330

Closed
awmleer opened this issue Jul 26, 2016 · 16 comments

Comments

Projects
None yet
10 participants
@awmleer
Copy link

commented Jul 26, 2016

我的django版本是1.9,Python版本是3.5
windows10系统

C:\Users\Hao\Project\django\xadmin>pip install django-xadmin
Collecting django-xadmin
  Using cached django-xadmin-0.5.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\Hao\AppData\Local\Temp\pip-build-tp9q6ucv\django-xadmin\setup.py", line 11, in <module>
        long_description=open('README.rst').read(),
    UnicodeDecodeError: 'gbk' codec can't decode byte 0xa4 in position 3256: illegal multibyte sequence

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\Hao\AppData\Local\Temp\pip-build-tp9q6ucv\django-xadmin\
@yinkh

This comment has been minimized.

Copy link

commented Dec 28, 2016

我也是 同样的问题

@mowujilun

This comment has been minimized.

Copy link

commented Jan 8, 2017

同样问题

@cupen

This comment has been minimized.

Copy link
Contributor

commented Feb 15, 2017

这个错误是因为 py3.0 之后 open 变了一下下,增加了一个 encoding 参数,未指定这个参数时 open 会使用默认的 locale 去读。我们的中文环境都是 gbk 的,于是…… 。

但以上都是小问题,真正的问题是 pypi 上太久没更新了。所以你安装的是超级旧的 py2.7 & django1.7 的版本,建议你直接从这个代码库里 git clone 一下。pip install git+https://github.com/sshwsfc/xadmin

@cupen

This comment has been minimized.

Copy link
Contributor

commented Feb 27, 2017

@awmleer @yinkanghong @mowujilun 搞定后就关掉这个 issue 吧。

@awmleer

This comment has been minimized.

Copy link
Author

commented Feb 27, 2017

我用的是mac了,pip install的时候没有出现这个问题,Linux的服务器上测试了也没问题,手头没有window的机子。。麻烦两位测试一下吧。@yinkanghong @mowujilun 多谢!

@cupen

This comment has been minimized.

Copy link
Contributor

commented Feb 28, 2017

@awmleer 我上面解释过了,py3 的 open 不加 encoding 参数的话就会用 locale 指定的编码。
你的 mac/linux 环境的 locale 可能是 utf-8( zh_CN.UTF-8 or en_US.UTF-8) 自然就没问题。但中文 Windows 都是 zh_CN.GBK, 妥妥要中镖的。

btw: 这个问题一直就有,因为这项目原本就不支持 py3。有段时间没关注了,现在支持与否在下也不知。先提个小 pr 改改 setup.py 应该不会粗啥大事。

@cupen cupen referenced this issue Feb 28, 2017

Merged

fix #330 #380

@yinkh

This comment has been minimized.

Copy link

commented Feb 28, 2017

`pip install xadmin
Collecting xadmin
Downloading xadmin-0.6.1.tar.gz (1.0MB)
100% |████████████████████████████████| 1.0MB 47kB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\ADMINI~1\AppData\Local\Temp\pip-build-731z13kc\xadmin\setup.py", line 11, in
long_description=open('README.rst').read(),
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa4 in position 3444: illegal multibyte sequence

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

Command "python setup.py egg_info" failed with error code 1 in C:\Users\ADMINI~1\AppData\Local\Temp\pip-build-731z13kc\xadmin
`
现在还是会有这个问题,我选择直接下载拷贝到项目里解决的,issue不是我提的,关不了哦。

@just10minutes

This comment has been minimized.

Copy link

commented Mar 2, 2017

Can anyone tell me is it possible to Run xadmin with python 3.5 django 1.10? if so what changes I need to do?

@awmleer

This comment has been minimized.

Copy link
Author

commented Mar 2, 2017

@just10minutes I'm using python 3.5.2 and django 1.10, when I run python manage.py runserver, I got the following exception:

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x106893400>
Traceback (most recent call last):
  File "/usr/local/opt/pyenv/versions/3.5.2/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/usr/local/opt/pyenv/versions/3.5.2/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 113, in inner_run
    autoreload.raise_last_exception()
  File "/usr/local/opt/pyenv/versions/3.5.2/lib/python3.5/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception
    six.reraise(*_exception)
  File "/usr/local/opt/pyenv/versions/3.5.2/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/opt/pyenv/versions/3.5.2/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/usr/local/opt/pyenv/versions/3.5.2/lib/python3.5/site-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/opt/pyenv/versions/3.5.2/lib/python3.5/site-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/usr/local/opt/pyenv/versions/3.5.2/lib/python3.5/site-packages/django/apps/config.py", line 90, in create
    module = import_module(entry)
  File "/usr/local/opt/pyenv/versions/3.5.2/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/usr/local/opt/pyenv/versions/3.5.2/lib/python3.5/site-packages/xadmin/__init__.py", line 4, in <module>
    from xadmin.sites import AdminSite, site
  File "/usr/local/opt/pyenv/versions/3.5.2/lib/python3.5/site-packages/xadmin/sites.py", line 10, in <module>
    reload(sys)
NameError: name 'reload' is not defined

Are you having the same problem?

@just10minutes

This comment has been minimized.

Copy link

commented Mar 3, 2017

Yes you are right.
Python 3 does not have reload.

In some other issues people have said they are able to use with python 3 by removing reload statement, but I was not successful in that.

@junweipan

This comment has been minimized.

Copy link

commented Feb 26, 2018

这个问题可以用源码安装的方式解决:
Installing from source

1,Download the latest source tarball from https://github.com/sshwsfc/django-xadmin or git clone the repository. Then execute the following in the project directory:

2,pip install -r requirements.txt

@win-hi

This comment has been minimized.

Copy link

commented Oct 11, 2018

pip 上不能更新下么?

@Veeupup

This comment has been minimized.

Copy link

commented Oct 30, 2018

现在这个问题还是存在,还有别的解决办法吗

@pabloyshi

This comment has been minimized.

Copy link

commented Jan 20, 2019

For Chinese system language users:
在 控制面板-区域-更改系统区域设置 中
勾选 Beta版:使用 Unicode UTF=8 提供全球语言支持(U) 选项
重启电脑后,就可以安装了。

@pabloyshi

This comment has been minimized.

Copy link

commented Jan 20, 2019

现在这个问题还是存在,还有别的解决办法吗

看楼上

@eliasyin

This comment has been minimized.

Copy link

commented Apr 15, 2019

For Chinese system language users:
在 控制面板-区域-更改系统区域设置 中
勾选 Beta版:使用 Unicode UTF=8 提供全球语言支持(U) 选项
重启电脑后,就可以安装了。

多谢~
pip install pyautogui
遇到相同问题,经该方法修改设置后再次安装就成功了
另外这样修改安装完所需要的package之后最好再改回去,不然有些地方会出现乱码(比如记事本)

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