dlwenliang125 2023-03-27 10:10 采纳率: 100%
浏览 15
已结题

windows 安装psycopg2 出现错误,如何解决?

安装 windows psycopg2 出现错误,该如何解决 python安装的是11 Postgresql也安装成功
PS E:\py_project> python -m pip install psycopg2
Collecting psycopg2
Downloading psycopg2-2.9.5-cp311-cp311-win32.whl (1.0 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/1.0 MB ? eta -:--:--
ERROR: Exception:
Traceback (most recent call last):
File "D:\Program Files\Python\Lib\site-packages\pip_vendor\urllib3\response.py", line 437, in _error_catcher
yield
File "D:\Program Files\Python\Lib\site-packages\pip_vendor\urllib3\response.py", line 560, in read
data = self._fp_read(amt) if not fp_closed else b""
^^^^^^^^^^^^^^^^^^
File "D:\Program Files\Python\Lib\site-packages\pip_vendor\urllib3\response.py", line 526, in _fp_read
return self._fp.read(amt) if amt is not None else self._fp.read()
^^^^^^^^^^^^^^^^^^
File "D:\Program Files\Python\Lib\site-packages\pip_vendor\cachecontrol\filewrapper.py", line 90, in read
data = self.__fp.read(amt)
^^^^^^^^^^^^^^^^^^^
File "D:\Program Files\Python\Lib\http\client.py", line 465, in read
s = self.fp.read(amt)
^^^^^^^^^^^^^^^^^
File "D:\Program Files\Python\Lib\socket.py", line 706, in readinto
return self._sock.recv_into(b)
^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Program Files\Python\Lib\ssl.py", line 1278, in recv_into
return self.read(nbytes, buffer)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Program Files\Python\Lib\ssl.py", line 1134, in read
return self._sslobj.read(len, buffer)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TimeoutError: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\Program Files\Python\Lib\site-packages\pip_internal\cli\base_command.py", line 160, in exc_logging_wrapper
status = run_func(*args)
^^^^^^^^^^^^^^^
File "D:\Program Files\Python\Lib\site-packages\pip_internal\cli\req_command.py", line 247, in wrapper
return func(self, options, args)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Program Files\Python\Lib\site-packages\pip_internal\commands\install.py", line 400, in run
requirement_set = resolver.resolve(
^^^^^^^^^^^^^^^^^
File "D:\Program Files\Python\Lib\site-packages\pip_internal\resolution\resolvelib\resolver.py", line 92, in resolve
result = self._result = resolver.resolve(
^^^^^^^^^^^^^^^^^
File "D:\Program Files\Python\Lib\site-packages\pip_vendor\resolvelib\resolvers.py", line 481, in resolve
state = resolution.resolve(requirements, max_rounds=max_rounds)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Program Files\Python\Lib\site-packages\pip_vendor\resolvelib\resolvers.py", line 348, in resolve
self._add_to_criteria(self.state.criteria, r, parent=None)
File "D:\Program Files\Python\Lib\site-packages\pip_vendor\resolvelib\resolvers.py", line 172, in _add_to_criteria
if not criterion.candidates:
File "D:\Program Files\Python\Lib\site-packages\pip_vendor\resolvelib\structs.py", line 151, in bool
return bool(self._sequence)
^^^^^^^^^^^^^^^^^^^^
File "D:\Program Files\Python\Lib\site-packages\pip_internal\resolution\resolvelib\found_candidates.py", line 155, in bool
return any(self)
^^^^^^^^^
File "D:\Program Files\Python\Lib\site-packages\pip_internal\resolution\resolvelib\found_candidates.py", line 143, in
return (c for c in iterator if id(c) not in self._incompatible_ids)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Program Files\Python\Lib\site-packages\pip_internal\resolution\resolvelib\found_candidates.py", line 47, in _iter_built
candidate = func()
^^^^^^
File "D:\Program Files\Python\Lib\site-packages\pip_internal\resolution\resolvelib\factory.py", line 206, in _make_candidate_from_link
self._link_candidate_cache[link] = LinkCandidate(
^^^^^^^^^^^^^^
File "D:\Program Files\Python\Lib\site-packages\pip_internal\resolution\resolvelib\candidates.py", line 297, in init
super().init(
File "D:\Program Files\Python\Lib\site-packages\pip_internal\resolution\resolvelib\candidates.py", line 162, in init
self.dist = self._prepare()
^^^^^^^^^^^^^^^
File "D:\Program Files\Python\Lib\site-packages\pip_internal\resolution\resolvelib\candidates.py", line 231, in _prepare
dist = self._prepare_distribution()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Program Files\Python\Lib\site-packages\pip_internal\resolution\resolvelib\candidates.py", line 308, in _prepare_distribution
return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Program Files\Python\Lib\site-packages\pip_internal\operations\prepare.py", line 491, in prepare_linked_requirement
return self._prepare_linked_requirement(req, parallel_builds)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Program Files\Python\Lib\site-packages\pip_internal\operations\prepare.py", line 536, in _prepare_linked_requirement
local_file = unpack_url(
^^^^^^^^^^^
File "D:\Program Files\Python\Lib\site-packages\pip_internal\operations\prepare.py", line 166, in unpack_url
file = get_http_url(
^^^^^^^^^^^^^
File "D:\Program Files\Python\Lib\site-packages\pip_internal\operations\prepare.py", line 107, in get_http_url
from_path, content_type = download(link, temp_dir.path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Program Files\Python\Lib\site-packages\pip_internal\network\download.py", line 147, in call
for chunk in chunks:
File "D:\Program Files\Python\Lib\site-packages\pip_internal\cli\progress_bars.py", line 53, in _rich_progress_bar
for chunk in iterable:
File "D:\Program Files\Python\Lib\site-packages\pip_internal\network\utils.py", line 63, in response_chunks
for chunk in response.raw.stream(
File "D:\Program Files\Python\Lib\site-packages\pip_vendor\urllib3\response.py", line 621, in stream
data = self.read(amt=amt, decode_content=decode_content)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Program Files\Python\Lib\site-packages\pip_vendor\urllib3\response.py", line 559, in read
with self._error_catcher():
File "D:\Program Files\Python\Lib\contextlib.py", line 155, in exit
self.gen.throw(typ, value, traceback)
File "D:\Program Files\Python\Lib\site-packages\pip_vendor\urllib3\response.py", line 442, in _error_catcher
raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.

  • 写回答

2条回答 默认 最新

  • Bony- 2023-03-27 11:17
    关注

    这个错误可能是由于网络超时导致的,可以尝试以下方法来解决:
    1、检查网络连接是否正常,如果网络不好,可以尝试更改网络或等待网络变得更加稳定。
    2、尝试使用以下命令重新安装 psycopg2:pip install psycopg2-binary。这个命令会自动安装二进制包,而不是编译源代码。这有可能会避免一些安装错误。
    3、如果第二步没有解决问题,可以尝试手动编译 psycopg2 的源代码。首先需要安装 PostgreSQL 的开发文件,然后再使用 pip 安装 psycopg2,如下所示:

    pip install --global-option=build_ext --global-option="-I/usr/include/postgresql" --global-option="-L/usr/lib" psycopg2
    

    如果 PostgreSQL 的开发文件安装在其他目录下,请相应地修改命令中的路径。希望这些方法能够帮助您解决问题!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 4月15日
  • 已采纳回答 4月7日
  • 创建了问题 3月27日

悬赏问题

  • ¥15 maccms影视模板 制作影视网站失败 求
  • ¥15 stm32按键设置闹钟数进退位不正常
  • ¥15 三电平逆变器中点电位平衡问题
  • ¥20 这怎么写啊 java课设
  • ¥15 用C语言完成一个复杂的游戏
  • ¥15 如何批量更改很多个文件夹里的文件名中包含文件夹名?
  • ¥50 MTK手机模拟HID鼠标出现卡顿
  • ¥20 求下下面这个数据结构代码
  • ¥20 前端 二进制文件流图片转化异常
  • ¥15 github上的这个C语言项目如何跑起来