-1

编辑:我得到了安装 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:没有名为“串行”的模块

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

4

1 回答 1

0

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

easy_install pip

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

sudo easy_install pip

使用以下命令安装 pyserial:

pip install pyserial

我希望这有帮助。

于 2018-09-09T22:05:29.300 回答