python - 安装 Python http 包时遇到问题
问题描述
我正在尝试将 Python http 包安装到我的 Mac 上的虚拟环境中,这样我就可以运行 Simple HTTP Server 但 pip 抱怨它无法从请求中导入请求:
% pip install http
...
ImportError: cannot import name 'Request' from 'request' (/Users/me/.virtualenvs/base/lib/python3.7/site-packages/request/__init__.py)
我最初安装了请求包,但这没有帮助。考虑到它可能需要请求,我也安装了它,但无济于事。
这是我的虚拟环境:
Package Version
---------------- ---------
certifi 2019.9.11
chardet 3.0.4
get 2019.4.13
idna 2.8
pip 19.3
post 2019.4.13
powerline-status 2.7
psycopg2-binary 2.8.3
public 2019.4.13
query-string 2019.4.13
request 2019.4.13
requests 2.22.0
setuptools 41.1.0
urllib3 1.25.6
wheel 0.33.4
我在从 virtualenv 16.6.2 构建的虚拟环境中运行 Python 3.7.4。在 macOS Mojave 上。
解决方案
您不必安装任何东西即可运行SimpleHTTPServer
。http
在标准库中。
另请注意,这SimpleHTTPServer
是http.server
在 Python 3 中调用的。
推荐阅读
- reactjs - 组件从状态更改重新渲染,但对 DOM 没有影响
- ruby - 什么是`&&=`快捷方式?
- java - 如何制作一个与外部硬件通信的 asnychron REST 服务器
- c# - 尝试在 SQL Server 中更新 datagridview 上的值
- sql - 在 SQL Server 中,BCP shell 命令不是在一个服务器中写入文件,而是在另一个服务器中创建文件。这个问题需要任何许可吗?
- javascript - 浏览器调整大小再次运行功能,我该怎么做?
- python - 这段代码可以更简单吗?哪个代码看起来更好?[反向循环]
- r - 始终使用列表中的一行 n 个其他数据框创建所有可能的数据框
- python - 熊猫 to_datetime 方法
- django - 如何在 Django 中通过 HttpResponse 或 JsonResponse 发送多个对象