Search code examples
pythonpippackageocpp

Getting error while installing OCPP in Python2.7


Iam trying to install OCPP in Python 2.7 using following command and getting the error shown below. plz help to resolve the issue

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.

I installed python 3.8 and reinstalled OCPP. After that Iam trying to simulate the central system and charge point of PyPi OCPP given in the following link https://pypi.org/project/ocpp/. Central system code runs without any error. but while compiling the charge point code i am getting the following error

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
>>> 

Solution

  • [PyPI]: ocpp (currently v0.8.1) only supports Python 3. However, same thing applies to v0.1.1 (very 1st OCPP version).

    So, the only way to proceed is install (and start using) Python 3, and give up Python 2(.7) (who is dead from the beginning of allmighty 2020 ([Python]: PEP 373 - Python 2.7 Release Schedule)).

    Of course, there's the (painful) alternative of porting OCPP code to Python 2, but I'd totally advice against it.