编辑:我已经获得安装pip和pyserial的帮助,但是导入序列在我的项目中不起作用。在我的文章结尾有更好的解释。
我正在尝试为学校项目安装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中使用?
答案 0 :(得分:0)
使用以下命令在Mac上安装pip:
easy_install pip
如果您需要管理员权限才能运行此程序,请尝试:
sudo easy_install pip
使用以下命令安装pyserial:
pip install pyserial
我希望这会有所帮助。