【问题标题】:Problems with pip, SSLException [duplicate]pip 的问题,SSLException [重复]
【发布时间】:2018-09-09 21:57:00
【问题描述】:

编辑:我得到了安装 pip 和 pyserial 的帮助,但是 import serial 在我的项目中不起作用。在我的帖子末尾更好地解释。

我正在尝试为学校项目安装 pyserial。

我想我之前一定是在安装或更改某些东西时搞砸了,因为我不太熟悉使用终端。

无论如何,我尝试了很多不同的方法,但都没有奏效。当我写

> python3 -m pip search pyserial

我得到了这个例外:

> Exception: Traceback (most recent call last):   File
> "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/_vendor/requests/packages/urllib3/connectionpool.py",
> line 544, in urlopen
>     body=body, headers=headers)   File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/_vendor/requests/packages/urllib3/connectionpool.py",
> line 341, in _make_request
>     self._validate_conn(conn)   File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/_vendor/requests/packages/urllib3/connectionpool.py",
> line 761, in _validate_conn
>     conn.connect()   File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/_vendor/requests/packages/urllib3/connection.py",
> line 238, in connect
>     ssl_version=resolved_ssl_version)   File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py", line 279, in ssl_wrap_socket
>     return context.wrap_socket(sock, server_hostname=server_hostname)   File
> "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py",
> line 376, in wrap_socket
>     _context=self)   File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py",
> line 747, in __init__
>     self.do_handshake()   File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py",
> line 983, in do_handshake
>     self._sslobj.do_handshake()   File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/ssl.py",
> line 628, in do_handshake
>     self._sslobj.do_handshake() ssl.SSLError: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version
> (_ssl.c:645)
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):   File
> "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/_vendor/requests/adapters.py",
> line 370, in send
>     timeout=timeout   File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/_vendor/requests/packages/urllib3/connectionpool.py",
> line 574, in urlopen
>     raise SSLError(e) pip._vendor.requests.packages.urllib3.exceptions.SSLError: [SSL:
> TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version
> (_ssl.c:645)
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):   File
> "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/basecommand.py",
> line 211, in main
>     status = self.run(options, args)   File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/commands/search.py",
> line 43, in run
>     pypi_hits = self.search(query, options)   File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/commands/search.py",
> line 60, in search
>     hits = pypi.search({'name': query, 'summary': query}, 'or')   File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/xmlrpc/client.py",
> line 1091, in __call__
>     return self.__send(self.__name, args)   File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/xmlrpc/client.py",
> line 1431, in __request
>     verbose=self.__verbose   File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/download.py",
> line 785, in request
>     headers=headers, stream=True)   File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/_vendor/requests/sessions.py",
> line 508, in post
>     return self.request('POST', url, data=data, json=json, **kwargs)   File
> "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/download.py",
> line 373, in request
>     return super(PipSession, self).request(method, url, *args, **kwargs)   File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/_vendor/requests/sessions.py",
> line 465, in request
>     resp = self.send(prep, **send_kwargs)   File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/_vendor/requests/sessions.py",
> line 573, in send
>     r = adapter.send(request, **kwargs)   File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/_vendor/cachecontrol/adapter.py",
> line 46, in send
>     resp = super(CacheControlAdapter, self).send(request, **kw)   File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pip/_vendor/requests/adapters.py",
> line 431, in send
>     raise SSLError(e, request=request) pip._vendor.requests.exceptions.SSLError: [SSL:
> TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version
> (_ssl.c:645)

有人对我能做什么有建议吗?

我也下载了一个包含该软件包的 zip 文件,但我不知道如何安装它,所以我同样迷路了。

感谢您的帮助!

多亏了很好的帮助,我想我已经接近修复它了。我现在可以在写的时候找到 pyserial

点子列表

但是,当我尝试将其导入 python 文件时,我得到了这个:

ImportError: 没有名为“serial”的模块

除了在终端中安装它之外,我还需要做什么才能在项目中使用它?是否有可能我已经安装了它以用于 Python 2 而不是我正在使用的 Python 3?

【问题讨论】:

  • 我已经编辑了我的问题以显示它与您发送的链接有何不同,但感谢您的建议。

标签: python pip pyserial sslexception


【解决方案1】:

使用以下命令在 Mac 上安装 pip:

easy_install pip

如果您需要管理员权限来运行它,请尝试:

sudo easy_install pip

使用以下命令安装pyserial:

pip install pyserial

我希望这会有所帮助。

【讨论】:

  • 然后我得到:-bash: pip: command not found
  • 当我尝试安装 pip 的命令时,我得到了同一行:-bash: pip: command not found
  • 谢谢!我认为这行得通! :D
  • 很高兴它对您有所帮助。 :)
  • 实际上..当我尝试使用它时它仍然无法工作:/ 当我运行一个导入串行的程序时,我收到了这个错误:ImportError: No module named 'serial'
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-02-17
  • 1970-01-01
  • 2016-03-21
  • 2018-09-21
  • 2021-05-11
  • 2014-08-07
  • 2012-02-12
相关资源
最近更新 更多