在 Python2.7 中安装 OCPP 时出错
Getting error while installing OCPP in Python2.7
我正在尝试使用以下命令在 Python 2.7 中安装 OCPP 并收到如下所示的错误。请帮忙解决问题
C:\Python27>python -m pip install ocpp
Collecting ocpp
Downloading https://files.pythonhosted.org/packages/36/f8/f3222edf8cf0f1a7373c9d5b0be0974959b3cf302906f0c59fe8bf4071f7/ocpp-0.1.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\vijaya~1\appdata\local\temp\pip-build-yaigdj\ocpp\setup.py", line 6, in <module>
with open(path.join(here, 'README.md'), encoding='utf-8') as f:
TypeError: 'encoding' is an invalid keyword argument for this function
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\vijaya~1\appdata\local\temp\pip-build-yaigdj\ocpp\
You are using pip version 9.0.1, however version 20.2.4 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
我安装了 python 3.8 并重新安装了 OCPP。之后,我尝试模拟以下 link https://pypi.org/project/ocpp/ 中给出的 PyPi OCPP 的中央系统和充电点。中央系统代码运行没有任何错误。但是在编译充电点代码时出现以下错误
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
====================== RESTART: C:/Python38/ocppserver.py ======================
INFO:root:WebSocket Server Started
====================== RESTART: C:\Python38\chargepoint.py =====================
Traceback (most recent call last):
File "C:\Python38\chargepoint.py", line 39, in <module>
asyncio.run(main())
File "C:\Python38\lib\asyncio\runners.py", line 43, in run
return loop.run_until_complete(main)
File "C:\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
return future.result()
File "C:\Python38\chargepoint.py", line 28, in main
async with websockets.connect(
File "C:\Python38\lib\site-packages\websockets\client.py", line 517, in __aenter__
return await self
File "C:\Python38\lib\site-packages\websockets\client.py", line 535, in __await_impl__
transport, protocol = await self._create_connection()
File "C:\Python38\lib\asyncio\base_events.py", line 1030, in create_connection
raise exceptions[0]
File "C:\Python38\lib\asyncio\base_events.py", line 1010, in create_connection
sock = await self._connect_sock(
File "C:\Python38\lib\asyncio\base_events.py", line 924, in _connect_sock
await self.sock_connect(sock, address)
File "C:\Python38\lib\asyncio\proactor_events.py", line 702, in sock_connect
return await self._proactor.connect(sock, address)
File "C:\Python38\lib\asyncio\windows_events.py", line 808, in _poll
value = callback(transferred, key, ov)
File "C:\Python38\lib\asyncio\windows_events.py", line 595, in finish_connect
ov.getresult()
ConnectionRefusedError: [WinError 1225] The remote computer refused the network connection
>>>
[PyPI]: ocpp(目前v0.8.1)仅支持Python 3。然而,同样的事情适用于 v0.1.1(非常 1st OCPP 版本)。
所以,唯一的方法就是安装(并开始使用)Python 3,然后放弃 Python 2 (.7)(谁从万能的2020年初就死了([Python]: PEP 373 - Python 2.7 Release Schedule))。
当然,将 OCPP 代码移植到 Python 2 是一个(痛苦的)替代方案,但我会完全反对它。
我正在尝试使用以下命令在 Python 2.7 中安装 OCPP 并收到如下所示的错误。请帮忙解决问题
C:\Python27>python -m pip install ocpp
Collecting ocpp
Downloading https://files.pythonhosted.org/packages/36/f8/f3222edf8cf0f1a7373c9d5b0be0974959b3cf302906f0c59fe8bf4071f7/ocpp-0.1.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\vijaya~1\appdata\local\temp\pip-build-yaigdj\ocpp\setup.py", line 6, in <module>
with open(path.join(here, 'README.md'), encoding='utf-8') as f:
TypeError: 'encoding' is an invalid keyword argument for this function
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\vijaya~1\appdata\local\temp\pip-build-yaigdj\ocpp\
You are using pip version 9.0.1, however version 20.2.4 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
我安装了 python 3.8 并重新安装了 OCPP。之后,我尝试模拟以下 link https://pypi.org/project/ocpp/ 中给出的 PyPi OCPP 的中央系统和充电点。中央系统代码运行没有任何错误。但是在编译充电点代码时出现以下错误
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
====================== RESTART: C:/Python38/ocppserver.py ======================
INFO:root:WebSocket Server Started
====================== RESTART: C:\Python38\chargepoint.py =====================
Traceback (most recent call last):
File "C:\Python38\chargepoint.py", line 39, in <module>
asyncio.run(main())
File "C:\Python38\lib\asyncio\runners.py", line 43, in run
return loop.run_until_complete(main)
File "C:\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
return future.result()
File "C:\Python38\chargepoint.py", line 28, in main
async with websockets.connect(
File "C:\Python38\lib\site-packages\websockets\client.py", line 517, in __aenter__
return await self
File "C:\Python38\lib\site-packages\websockets\client.py", line 535, in __await_impl__
transport, protocol = await self._create_connection()
File "C:\Python38\lib\asyncio\base_events.py", line 1030, in create_connection
raise exceptions[0]
File "C:\Python38\lib\asyncio\base_events.py", line 1010, in create_connection
sock = await self._connect_sock(
File "C:\Python38\lib\asyncio\base_events.py", line 924, in _connect_sock
await self.sock_connect(sock, address)
File "C:\Python38\lib\asyncio\proactor_events.py", line 702, in sock_connect
return await self._proactor.connect(sock, address)
File "C:\Python38\lib\asyncio\windows_events.py", line 808, in _poll
value = callback(transferred, key, ov)
File "C:\Python38\lib\asyncio\windows_events.py", line 595, in finish_connect
ov.getresult()
ConnectionRefusedError: [WinError 1225] The remote computer refused the network connection
>>>
[PyPI]: ocpp(目前v0.8.1)仅支持Python 3。然而,同样的事情适用于 v0.1.1(非常 1st OCPP 版本)。
所以,唯一的方法就是安装(并开始使用)Python 3,然后放弃 Python 2 (.7)(谁从万能的2020年初就死了([Python]: PEP 373 - Python 2.7 Release Schedule))。
当然,将 OCPP 代码移植到 Python 2 是一个(痛苦的)替代方案,但我会完全反对它。