python 在jupyter笔记本上安装库时出现错误

2cmtqfgy  于 2023-06-28  发布在  Python
关注(0)|答案(1)|浏览(288)

我想安装这个库

!pip install tensorflow==2.4.1 tensorflow-gpu==2.4.1 opencv-python mediapip sklearn matplotlib

结果就是这样

AttributeError                            Traceback (most recent call last)
Cell In[1], line 1
----> 1 get_ipython().system('pip install tensorflow==2.4.1 tensorflow-gpu==2.4.1 opencv-python mediapip sklearn matplotlib')

File /lib/python3.11/site-packages/IPython/core/interactiveshell.py:2590, in InteractiveShell.system_piped(self, cmd)
   2585     raise OSError("Background processes not supported.")
   2587 # we explicitly do NOT return the subprocess status code, because
   2588 # a non-None value would trigger :func:`sys.displayhook` calls.
   2589 # Instead, we store the exit_code in user_ns.
-> 2590 self.user_ns['_exit_code'] = system(self.var_expand(cmd, depth=1))

File /lib/python3.11/site-packages/IPython/utils/_process_posix.py:129, in ProcessHandler.system(self, cmd)
    125 enc = DEFAULT_ENCODING
    127 # Patterns to match on the output, for pexpect.  We read input and
    128 # allow either a short timeout or EOF
--> 129 patterns = [pexpect.TIMEOUT, pexpect.EOF]
    130 # the index of the EOF pattern in the list.
    131 # even though we know it's 1, this call means we don't have to worry if
    132 # we change the above list, and forget to change this value:
    133 EOF_index = patterns.index(pexpect.EOF)

AttributeError: module 'pexpect' has no attribute 'TIMEOUT
xesrikrc

xesrikrc1#

错误消息表明pexpect模块有问题,特别是TIMEOUT属性。
要解决此问题,您可以尝试使用以下命令重新安装pexpect模块:

!pip uninstall pexpect
!pip install pexpect

重新安装pexpect模块后,再次尝试运行安装命令:

!pip install tensorflow==2.4.1 tensorflow-gpu==2.4.1 opencv-python mediapip sklearn matplotlib

这应该可以修复与pexpect.TIMEOUT相关的AttributeError。

相关问题