According to the python3.5 documentation there should be a Handle
called timeout in the asyncio module ->documentation.
But if I try to use it python3.5 tells me, that there is no asyncio.timeout:
$ python3.5
Python 3.5.0+ (default, Oct 11 2015, 09:05:38)
[GCC 5.2.1 20151010] on linux
>>> import asyncio
>>> asyncio.timeout(3)
AttributeError: module 'asyncio' has no attribute 'timeout'
I have already searched the web, but I was unable to find any solution.
I am using Linux <my hostname> 4.2.0-27-generic #32-Ubuntu SMP Fri Jan 22 04:49:08 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux.
So how can I use asyncio.timeout, why isn't it where it should be, or how can I bypass my problem?
It will appear in Python 3.5.2
For now you can use Timeout class from aiohttp with the same behavior.
Related
I'm trying to run MinimalModbus (which uses pyserial under the hood) on Windows 7, and I've reduced my issue to this: Here's the contents of foo.py in its entirety:
#!/usr/bin/env python
import sys
import serial
print(sys.version)
print(serial.PARITY_NONE)
When I run foo.py, python cannot find some pyserial attributes:
E:\>py -3.6 foo.py
3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)]
Traceback (most recent call last):
File "foo.py", line 5, in <module>
print(serial.PARITY_NONE)
AttributeError: module 'serial' has no attribute 'PARITY_NONE'
When I run the same script on OS X (High Sierra, 10.13.2), I get the correct output ('N').
Here is the output of pip freeze and ver in my Windows environment:
E:\>py -3.6 -m pip freeze
future==0.16.0
iso8601==0.1.12
MinimalModbus==0.7
pyftdi==0.28.2
pyserial==3.4
pyusb==1.0.2
PyYAML==3.12
serial==0.0.27
UniCurses==1.2
E:\>ver
Microsoft Windows [Version 6.1.7601]
Any suggestions?
update
It appears that I'm getting the wrong serial module:
E:\>py -3.6
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import serial
>>> help(serial)
Help on package serial:
NAME
serial
DESCRIPTION
``serial`` is an object serialization/deserialization library intended to fa
cilitate authoring of API models which are
readable and introspective, and to expedite code and data validation and tes
ting. ``serial`` supports JSON, YAML, and
XML.
... which isn't at all the pyserial module I've come to love. What am I missing?
A somewhat anticlimactic solution.
I noticed the offending serial module in the output of pip freeze:
E:\>py -3.6 -m pip freeze
future==0.16.0
iso8601==0.1.12
MinimalModbus==0.7
pyftdi==0.28.2
pyserial==3.4
pyusb==1.0.2
PyYAML==3.12
serial==0.0.27 <<< this one
UniCurses==1.2
I removed it:
py -3.6 -m pip uninstall serial
... but that didn't fix the problem. However, subsequently uninstalling and re-installing pyserial did the trick:
>>> py -3.6 -m pip uninstall pyserial
>>> py -3.6 -m pip install pyserial
>>> py -3.6 foo.py
3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)]
N
All better now!
I installed python 3.4 on OS X (10.9.5) but can't seem to reference it.
Here's a test file to see what version
#!/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4.3
import sys
print(sys.version)
result prints as: 2.7.5 (default, Mar 9 2014, 22:15:05)
i also tried:
#!/usr/bin/python3
and
#!/usr/bin/python3.4
and both return the same thing: 2.7.5 (default, Mar 9 2014, 22:15:05)
not sure what's going on inside the folder /Library/Frameworks/Python.framework/Versions/3.4/bin/ I can see Python 3.4 config files and directories? is this just a place where Python was unzipped, am I still yet to install it or something?
I've installed Python 2.7 and python 3.4 on my system. Earlier i was using 3.4 but now require 2.7 as well (for a course I'm taking, which requires some files which are not there for 3.4). When I type python in cmd it by default initializes 3.4. Is there some way to change it to 2.7 by default?
Thanks
UPDATE: I was able to invoke it using 'py'. Here's the link if anyone else has a confusion. https://docs.python.org/3/using/windows.html?highlight=shebang#python-launcher-for-windows (from some other answer)
Update:
If your system environment is Windows:
1) call py -2.7 or py -3 based on the version you want.
2) change your PATH system environment variable , makes sure it refers to the version you want.
You can do it in serveral ways on Linux environment:
1)
call a specific Python binary you can call the explicit full path (e. g. /usr/local/bin/python). This will call the same executable regardless of the value of the $PATH variable.
2)
configure your accounts so that both have the same binary first in the $PATH variable.
3)
call python2 and python3; many installations symlink these to the corresponding binaries.
$ python2
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
$ python3
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
I use go.net/html in my project on work and everything is ok. But when I try to install this package on my laptop I get a error:
termith#termith-laptop:~/go$ go get code.google.com/p/go.net/html
# code.google.com/p/go.net/html
src/code.google.com/p/go.net/html/token.go:304: undefined: io.ErrNoProgress
My system:
termith#termith-laptop:~/go$ uname -a
Linux termith-laptop 3.2.0-51-generic-pae #77-Ubuntu SMP Wed Jul 24 20:40:32 UTC 2013
i686 i686 i386 GNU/Linux
Thanks in advance!
You most likely have an outdated Go version (see for example this GitHub issue).
Check the output of go version and update if necessary.
Beware: the go.net package url will change with Go 1.4:
code.google.com/p/go.net => golang.org/x/net
If you update (again) your go version (to 1.4, once released, November 9th, 2014), you might have to change that import path.
See "Go 1.4 subrepo renaming".
I'm having trouble listing available serial ports and I really need help debugging this.
In Python 2.7.5 the COM-ports are listed correctly while PySerial returns an empty list in Python 3.3.5.
I found one other lonely soul with the same problems on the internet (no answers), but the problem doesn't seem to be popular at all - maybe it's my system?
I'm using Mac OS X 10.9.2 and installed python and python3 via homebrew. I updated everything just now. PySerial is at version 2.7 in both pip and pip3.
The output:
Python 2.7.5 (default, Nov 4 2013, 18:04:45)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from serial.tools import list_ports
>>> list_ports.comports()
[['/dev/cu.Bluetooth-Incoming-Port', 'n/a', 'n/a'], ['/dev/cu.Bluetooth-Modem', 'n/a', 'n/a']]
Python 3.3.5 (default, Mar 10 2014, 13:25:50)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from serial.tools import list_ports
>>> list_ports.comports()
[]
For the moment I'm resorting to the following method. The PySerial tools are broken.
>>> import glob
>>> glob.glob('/dev/tty.*')
['/dev/tty.Bluetooth-Incoming-Port', '/dev/tty.Bluetooth-Modem']
The root cause of the problem stems from the fact that python3 encodes strings as unicode (wide) strings, and python2 encodes strings as narrow strings.
So the pyserial code needs to pass down narrow strings when calling the API functions from iokit.
I discovered that somebody else also ran into this and posted a patch. You can find his patch at the end of this issue:
http://sourceforge.net/p/pyserial/patches/38/
Using that patch, I now get the same behaviour from python3 as I do from python2.
I had installed python3 using macports, and my installation of pyserial for python3 was found in this directory:
/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/serial
so I executed the following:
cd /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/serial/tools
sudo cp list_ports_osx.py list_ports_osx_orig.py
sudo curl -O http://sourceforge.net/p/pyserial/patches/_discuss/thread/603bd426/55a8/attachment/list_ports_osx.py
and that made list_ports.comports() work for me.