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
>>>
[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.
Related
I keep getting the error
Command "python setup.py egg_info" failed with error code 1 in C:\Users\HP\AppData\Local\Temp\pip-install-sv33cp8y\tables\
when trying to use
pip install tables
I've tried
pip install --upgrade setuptools
and quite a few other things but still can't get it to work.
The full error that I'm getting is:
Collecting tables
Using cached https://files.pythonhosted.org/packages/4d/53/8f34ce887c2a2ad80518980419a5f6f41defc85a287a355987e559ce9385/tables-3.4.4.tar.gz
Complete output from command python setup.py egg_info:
* Using Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)]
* USE_PKGCONFIG: False
Traceback (most recent call last):
File "c:\python37\lib\site-packages\setuptools\msvc.py", line 489, in _find_latest_available_vc_ver
return self.find_available_vc_vers()[-1]
IndexError: list index out of range
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\HP\AppData\Local\Temp\pip-install-5bjrxgs8\tables\setup.py", line 633, in <module>
libraries=(package.library_name,))
File "c:\python37\lib\distutils\ccompiler.py", line 791, in has_function
objects = self.compile([fname], include_dirs=include_dirs)
File "c:\python37\lib\distutils\_msvccompiler.py", line 345, in compile
self.initialize()
File "c:\python37\lib\distutils\_msvccompiler.py", line 238, in initialize
vc_env = _get_vc_env(plat_spec)
File "c:\python37\lib\site-packages\setuptools\msvc.py", line 185, in msvc14_get_vc_env
return EnvironmentInfo(plat_spec, vc_min_ver=14.0).return_env()
File "c:\python37\lib\site-packages\setuptools\msvc.py", line 843, in __init__
self.si = SystemInfo(self.ri, vc_ver)
File "c:\python37\lib\site-packages\setuptools\msvc.py", line 485, in __init__
self.vc_ver = vc_ver or self._find_latest_available_vc_ver()
File "c:\python37\lib\site-packages\setuptools\msvc.py", line 492, in _find_latest_available_vc_ver
raise distutils.errors.DistutilsPlatformError(err)
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\HP\AppData\Local\Temp\pip-install-5bjrxgs8\tables\
I'm basically trying to convert a hdf5 file into a csv and I just can't get it to work or anything at the moment.
Might be a permission issue.
Try :
sudo pip install --upgrade setuptools
Also refer to the discussion here. Some folks had this problem with python version.
I'm trying to add Channels to my app by following this tutorial:
https://blog.heroku.com/in_deep_with_django_channels_the_future_of_real_time_apps_in_django
The Django app compiles, but when I try to run it:
(virtualenv) root#computer:path# python manage.py runserver 0.0.0.0:8000
It gives error:
File "/root/.virtualenvs/codebench/local/lib/python2.7/site-packages/channels/routing.py", line 75, in resolve_routing
raise ImproperlyConfigured("Cannot import channel routing %r: %s" % (routing, e))
ImproperlyConfigured: Cannot import channel routing 'codebench.routing.channel_routing': cannot import name ProtocolTypeRouter
According to this
https://github.com/VincentTide/django-channels-celery-example/issues/1
It maybe related to Python version, so I did:
(virtualenv) root#computer:path# alias python=python3
(virtualenv) root#computer:path# python -V
Python 3.5.2
(virtualenv) root#computer:path# python manage.py runserver 0.0.0.0:8000
Traceback (most recent call last):
File "manage.py", line 3, in <module>
import eventlet
ImportError: No module named 'eventlet'
(virtualenv) root#computer:path# pip install eventlet
Requirement already satisfied: eventlet in /root/.virtualenvs/codebench/lib/python2.7/site-packages
Requirement already satisfied: greenlet>=0.3 in /root/.virtualenvs/codebench/lib/python2.7/site-packages (from eventlet)
Requirement already satisfied: enum-compat in /root/.virtualenvs/codebench/lib/python2.7/site-packages (from eventlet)
Requirement already satisfied: enum34 in /root/.virtualenvs/codebench/lib/python2.7/site-packages (from enum-compat->eventlet)
Now I stuck at: ImportError: No module named 'eventlet'
I have the following packages installed:
channels==1.1.6
daphne==1.4.0
Django==1.9
eventlet==0.20.0
If I follow this tutorial: http://channels.readthedocs.io/en/1.x/getting-started.html
System check identified 1 issue (0 silenced).
February 16, 2018 - 23:19:32
Django version 1.9, using settings 'codebench.settings'
Starting Channels development server at http://0.0.0.0:8000/
Channel layer default (asgiref.inmemory.ChannelLayer)
Quit the server with CONTROL-C.
2018-02-16 23:19:32,935 - INFO - worker - Listening on channels http.request, websocket.connect, websocket.disconnect, websocket.receive
2018-02-16 23:19:32,935 - INFO - worker - Listening on channels http.request, websocket.connect, websocket.disconnect, websocket.receive
2018-02-16 23:19:32,935 - INFO - worker - Listening on channels http.request, websocket.connect, websocket.disconnect, websocket.receive
2018-02-16 23:19:32,936 - INFO - worker - Listening on channels http.request, websocket.connect, websocket.disconnect, websocket.receive
Traceback (most recent call last):
File "/root/.virtualenvs/codebench/local/lib/python2.7/site-packages/eventlet/hubs/hub.py", line 457, in fire_timers
timer()
File "/root/.virtualenvs/codebench/local/lib/python2.7/site-packages/eventlet/hubs/timer.py", line 58, in __call__
cb(*args, **kw)
File "/root/.virtualenvs/codebench/local/lib/python2.7/site-packages/eventlet/semaphore.py", line 145, in _do_acquire
waiter.switch()
File "/root/.virtualenvs/codebench/local/lib/python2.7/site-packages/eventlet/green/thread.py", line 41, in __thread_body
func(*args, **kwargs)
File "/root/.virtualenvs/codebench/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/root/.virtualenvs/codebench/local/lib/python2.7/site-packages/channels/management/commands/runserver.py", line 99, in inner_run
websocket_handshake_timeout=self.websocket_handshake_timeout,
File "/root/.virtualenvs/codebench/local/lib/python2.7/site-packages/daphne/server.py", line 101, in run
websocket_handshake_timeout=self.websocket_handshake_timeout
TypeError: __init__() got an unexpected keyword argument 'proxy_forwarded_proto_header'
If I upgrade everything, except Python 2.7.12:
asgi-redis==1.4.3
asgiref==2.1.5
channels==2.0.2
daphne==2.0.3
Django==1.11.10
runserver will give:
File "/root/.virtualenvs/codebench/local/lib/python2.7/site-packages/channels/apps.py", line 6, in <module>
import daphne.server # noqa
File "/root/.virtualenvs/codebench/local/lib/python2.7/site-packages/daphne/server.py", line 192
async def handle_reply(self, protocol, message):
^
SyntaxError: invalid syntax
If I try to reinstall all required packages under Python 3.5.2:
Need this for twisted:
apt install python3.6-dev
https://askubuntu.com/questions/966939/failed-building-wheel-for-twisted
Now I'm getting random errors:
2018-02-18 14:03:51,634 - ERROR - server - Exception inside application: 'NoneType' object has no attribute 'writeSequence'
File "/usr/lib/python3.5/asyncio/tasks.py", line 241, in _step
result = coro.throw(exc)
File "/root/.virtualenvs/python3/lib/python3.5/site-packages/channels/http.py", line 191, in __call__
await self.handle(body)
File "/root/.virtualenvs/python3/lib/python3.5/site-packages/asgiref/sync.py", line 108, in __call__
return await asyncio.wait_for(future, timeout=None)
File "/usr/lib/python3.5/asyncio/tasks.py", line 373, in wait_for
return (yield from fut)
File "/usr/lib/python3.5/asyncio/futures.py", line 361, in __iter__
yield self # This tells Task to wait for completion.
File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
future.result()
File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
raise self._exception
File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
result = self.fn(*self.args, **self.kwargs)
File "/root/.virtualenvs/python3/lib/python3.5/site-packages/asgiref/sync.py", line 123, in thread_handler
return self.func(*args, **kwargs)
File "/root/.virtualenvs/python3/lib/python3.5/site-packages/channels/http.py", line 227, in handle
self.send(response_message)
File "/root/.virtualenvs/python3/lib/python3.5/site-packages/asgiref/sync.py", line 62, in __call__
return call_result.result()
File "/usr/lib/python3.5/concurrent/futures/_base.py", line 405, in result
return self.__get_result()
File "/usr/lib/python3.5/concurrent/futures/_base.py", line 357, in __get_result
raise self._exception
File "/root/.virtualenvs/python3/lib/python3.5/site-packages/asgiref/sync.py", line 76, in main_wrap
result = await self.awaitable(*args, **kwargs)
File "/root/.virtualenvs/python3/lib/python3.5/site-packages/daphne/server.py", line 196, in handle_reply
protocol.handle_reply(message)
File "/root/.virtualenvs/python3/lib/python3.5/site-packages/daphne/http_protocol.py", line 210, in handle_reply
http.Request.write(self, message.get("body", b""))
File "/root/.virtualenvs/python3/lib/python3.5/site-packages/twisted/web/http.py", line 1084, in write
self.channel.writeSequence(toChunk(data))
'NoneType' object has no attribute 'writeSequence'
Also:
(python3) root#computer:path# python manage.py shell
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import channels
>>> print(channels.__file__)
/root/.virtualenvs/python3/lib/python3.5/site-packages/channels/__init__.py
>>> from channels import Group
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: cannot import name 'Group'
It looks as if you created a Python 2 virtualenv. Setting alias python=python3 won't work. You need to create a virtualenv using Python 3, for example:
python3 -m venv newenv
Then re-install your requirements in the new virtualenv.
Once you have activated the new environment, python will be python3. You won't need to set alias python=python3.
I end up with the following versions:
asgi-redis==0.8.3
asgiref==0.9
autobahn==0.12.1
channels==0.9.3
daphne==0.9.1
dj-database-url==0.4.0
Django==1.9.3
haikunator==1.0.1
msgpack-python==0.4.7
psycopg2==2.7.4
redis==2.10.5
six==1.10.0
Twisted==15.5.0
txaio==2.2.1
zope.interface==4.1.3
Turned out Python version doesn't matter, works with both 2.7 and 3.5.
Because I was installing the https://github.com/jacobian/channels-example,
I also changed the database from MySQL to PostgreSQL. This example works like a charm.
I'm trying to install twisted
pip install https://pypi.python.org/packages/18/85/eb7af503356e933061bf1220033c3a85bad0dbc5035dfd9a97f1e900dfcb/Twisted-16.2.0.tar.bz2#md5=8b35a88d5f1a4bfd762a008968fddabf
This is for a django-channels project and I'm having the following error problem
Exception:
Traceback (most recent call last):
File "/home/petarp/.virtualenvs/ErasmusCloneFromGitHub/lib/python3.5/tarfile.py", line 1655, in bz2open
import bz2
File "/usr/local/lib/python3.5/bz2.py", line 22, in <module>
from _bz2 import BZ2Compressor, BZ2Decompressor
ImportError: No module named '_bz2'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/petarp/.virtualenvs/CloneFromGitHub/lib/python3.5/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/home/petarp/.virtualenvs/ErasmusCloneFromGitHub/lib/python3.5/site-packages/pip/commands/install.py", line 310, in run
wb.build(autobuilding=True)
File "/home/petarp/.virtualenvs/ErasmusCloneFromGitHub/lib/python3.5/site-packages/pip/wheel.py", line 750, in build
self.requirement_set.prepare_files(self.finder)
File "/home/petarp/.virtualenvs/ErasmusCloneFromGitHub/lib/python3.5/site-packages/pip/req/req_set.py", line 370, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/home/petarp/.virtualenvs/ErasmusCloneFromGitHub/lib/python3.5/site-packages/pip/req/req_set.py", line 587, in _prepare_file
session=self.session, hashes=hashes)
File "/home/petarp/.virtualenvs/ErasmusCloneFromGitHub/lib/python3.5/site-packages/pip/download.py", line 810, in unpack_url
hashes=hashes
File "/home/petarp/.virtualenvs/ErasmusCloneFromGitHub/lib/python3.5/site-packages/pip/download.py", line 653, in unpack_http_url
unpack_file(from_path, location, content_type, link)
File "/home/petarp/.virtualenvs/ErasmusCloneFromGitHub/lib/python3.5/site-packages/pip/utils/__init__.py", line 605, in unpack_file
untar_file(filename, location)
File "/home/petarp/.virtualenvs/ErasmusCloneFromGitHub/lib/python3.5/site-packages/pip/utils/__init__.py", line 538, in untar_file
tar = tarfile.open(filename, mode)
File "/home/petarp/.virtualenvs/ErasmusCloneFromGitHub/lib/python3.5/tarfile.py", line 1580, in open
return func(name, filemode, fileobj, **kwargs)
File "/home/petarp/.virtualenvs/ErasmusCloneFromGitHub/lib/python3.5/tarfile.py", line 1657, in bz2open
raise CompressionError("bz2 module is not available")
tarfile.CompressionError: bz2 module is not available
Clearly I'm missing bz2 module, so I've tried to installed it manually, but that didn't worked out for python 3.5, so how can I solved this?
I've did what #e4c5 suggested but I did it for python3.5.1, the output is
➜ ~ python3.5
Python 3.5.1 (default, Apr 19 2016, 22:45:11)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import bz2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/bz2.py", line 22, in <module>
from _bz2 import BZ2Compressor, BZ2Decompressor
ImportError: No module named '_bz2'
>>>
[3] + 18945 suspended python3.5
➜ ~ dpkg -S /usr/local/lib/python3.5/bz2.py
dpkg-query: no path found matching pattern /usr/local/lib/python3.5/bz2.py
I am on Ubuntu 14.04 LTS and I have installed python 3.5 from source.
I don't seem to have any problem with import bz2 on my python 3.4 installation. So I did
import bz2
print (bz2.__file__)
And found that it's located at /usr/lib/python3.4/bz2.py then I did
dpkg -S /usr/lib/python3.4/bz2.py
This reveals:
libpython3.4-stdlib:amd64: /usr/lib/python3.4/bz2.py
Thus the following command should hopefully fix this:
apt-get install libpython3.4-stdlib
Update:
If you have compiled python 3.5 from sources, it's very likely the bz2 hasn't been compiled in. Please reinstall by first doing
./configure --with-libs='bzip'
The same applies for python 3.6 as well. Note that this will probably complain about other missing dependencies. You will have to install the missing dependencies one by one until everything is covered.
I was able to solve it by removing the _ and changing the import to
from bz2 import BZ2Compressor, BZ2Decompressor
On ubuntu, apt-get install libbz2-dev then compile python again.
I use command 'pip install tables' in powershell (Windows) to install Pytables. Yet I receive the ValueError: [u'path'].
In red is written 'Command "python setup.py egg_info" failed with error code 1'.
I have miniconda installed.
EDIT: the full red error message is the following:
'Command "python setup.py egg_info" failed with error code 1 in c:\users\evert\appdata\local\temp\pip-build-9wkucl\tables
\'
Between my pip install command and the red error message is written the following:
Collecting tables
Using cached tables-3.2.2.tar.gz
Complete output from command python setup.py egg_info:
* Using Python 2.7.11 |Continuum Analytics, Inc.| (default, Feb 16 2016, 09:58:36) [MSC v.1500 64 bit (AMD64)]
* USE_PKGCONFIG: False
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\evert\appdata\local\temp\pip-build-9wkucl\tables\setup.py", line 553, in <module>
libraries=(package.library_name,))
File "c:\users\evert\miniconda2\lib\distutils\ccompiler.py", line 758, in has_function
objects = self.compile([fname], include_dirs=include_dirs)
File "c:\users\evert\miniconda2\lib\distutils\msvc9compiler.py", line 473, in compile
self.initialize()
File "c:\users\evert\miniconda2\lib\distutils\msvc9compiler.py", line 383, in initialize
vc_env = query_vcvarsall(VERSION, plat_spec)
File "c:\users\evert\miniconda2\lib\site-packages\setuptools-20.3-py2.7.egg\setuptools\msvc9_support.py", line 52,
in query_vcvarsall
File "c:\users\evert\miniconda2\lib\distutils\msvc9compiler.py", line 299, in query_vcvarsall
raise ValueError(str(list(result.keys())))
ValueError: [u'path']
Which part is missing? Which steps should I execute before running 'pip install tables'?
Thank you for your help.
This is a problem with not being able to correctly setup certain environment variables required for the setup using vcvarsall.bat. You can download a binary of pytables here instead and do pip install tables-3.2.2-*.whl. Be sure to download the binary matching your version and system architecture.
When I run python pip on a new brand Ubuntu 15.04 system with all updates installed, I get the following assertion error. This is with Python 2.7.x. I get a very similar result with Python 3.4.x:
➜ pip list
adium-theme-ubuntu (0.3.4)
<...snip...>
pyOpenSSL (0.13.1)
pyserial (2.6)
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/list.py", line 80, in run
self.run_listing(options)
File "/usr/lib/python2.7/dist-packages/pip/commands/list.py", line 142, in run_listing
self.output_package_listing(installed_packages)
File "/usr/lib/python2.7/dist-packages/pip/commands/list.py", line 151, in output_package_listing
if dist_is_editable(dist):
File "/usr/lib/python2.7/dist-packages/pip/util.py", line 367, in dist_is_editable
req = FrozenRequirement.from_dist(dist, [])
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 299, in from_dist
assert len(specs) == 1 and specs[0][0] == '=='
AssertionError
I think you should report this as a bug here. I can reproduce it in my Ubuntu 15.04 (64bit). The man page clearly states the pip list and pip3 list commands should simply list the packages, but in both cases they crash with AssertionError before completing.