已安装Python软件包,但无法使用,pip搜索会引发回溯

时间:2018-08-27 10:29:10

标签: python-3.x pip

我已经安装了一个要代替SimpleHTTPServer使用的软件包,由于某些原因,该软件包无法正常工作:

# python3 -m pip install http-here
Requirement already satisfied: http-here in /usr/local/lib/python3.5/dist-packages
Requirement already satisfied: click in /usr/local/lib/python3.5/dist-packages (from http-here)

但是在尝试使用它时,出现了此错误:

  # python3 -m http-here
/usr/bin/python3: No module named http-here

在其他输出中的点搜索显示回溯:

# python3 -m pip search http-here
http-here (0.0.2)        - Simple Python HTTP server short for SimpleHTTPServer.
  INSTALLED: 0.0.2 (latest)

--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.5/logging/__init__.py", line 983, in emit
    stream.write(msg)
UnicodeEncodeError: 'ascii' codec can't encode character '\ub294' in position 78: ordinal not in range(128)
Call stack:
  File "/usr/lib/python3.5/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3/dist-packages/pip/__main__.py", line 19, in <module>
    sys.exit(pip.main())
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 233, in main
    return command.main(cmd_args)
  File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/commands/search.py", line 52, in run
    print_results(hits, terminal_width=terminal_width)
  File "/usr/lib/python3/dist-packages/pip/commands/search.py", line 118, in print_results
    logger.info(line)
Message: 'hacked-http (0.0.1)                                          - Hacked Urllib2 \ub294 warning.or.kr \uac19\uc740 \ubc29\uc5b4\ubcbd\uc744 \ub6ab\ub294\ub370 \ubaa9\uc801\uc774 \uc788\uc2b5\ub2c8\ub2e4.'

被盗的Urllib2 是我关注的问题。

我的Python和pip版本:

# python3 -V
Python 3.5.3
# python3 -m pip -V
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.5)

此外,要安装 python3-pip 接缝,但在通过CLI调用时也无效:

# apt install python3-pip
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-pip is already the newest version (9.0.1-2).
0 upgraded, 0 newly installed, 0 to remove and 40 not upgraded.

# python3-pip search whatever
-bash: python3-pip: command not found

# which python3
/usr/bin/python3

我的语言环境输出顽固地显示了一些空字段,这可能是回溯的原因,我应该在/ etc / environment中编写它吗?

# locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE=UTF-8
...
LC_ALL=

我遇到一些需要报告的python bug或如何解决此问题? 谢谢。

1 个答案:

答案 0 :(得分:0)

回答我自己的问题:

添加

export LC_ALL="en_US.UTF-8" export LANGUAGE="en_US.UTF-8" export LC_CTYPE="en_US.UTF-8"

/etc/profile~/.profile~/.bashrc进行操作,以确保不再发生这种情况,请摆脱回溯。

关于 Hacked Urllib2 pip search显示可用的软件包(未安装)以查看是否已安装,我已经使用过pip list,但没有这个垃圾桶了。 >

关于

# python3 -m http-here
/usr/bin/python3: No module named http-here

应称为pip3

还有

python3 -m http.server
Serving HTTP on 0.0.0.0 port 8000 ...

应该代替用于Python2的SimpleHTTPServer