I've installed Python 3.3 on a Windows 7 machine. I wanted to try to the Bottle micro web
framework. I downloaded the bottle.py (latest version from their site) and put it in my app
folder.
When I do the first line in the tutorial, "from bottle import route, run, template"
I got this error message:
*C:\Dev>python
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:57:17) [MSC v.1600 64 bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from bottle import route,run,template
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".\bottle.py", line 564
raise exc_info[0], exc_info[1], exc_info[2]
^
SyntaxError: invalid syntax
>>>*
Any suggestions how I can fix this problem and continue?
Thanks
You need to follow the bottle installation instructions.
The latest version is published to PyPI, you have an old version of the code there still, one that is not compatible with Python 3.
The format
raise Exception, args
is not there anymore in Python 3+.
That is why the statement is throwing syntax error:
raise exc_info[0], exc_info[1], exc_info[2]
That was a bug introduced 5 days ago and fixed today. Just download bottle.py again. Or use a stable release as suggested by Martijn Pieters
Related
I'm working with pykd and am able to connect it with my debugger (windbg) but for some reason I'm unable to process any command with pykd.dbgCommand not sure what the issue is as I've tried multiple methods to try and resolve the issue:
Reinstall pydk + python
tried on python2.7, python3.5, python3.8
tried a different system + different debug session
when I tried to run the command on the windbg session it was able to produce the results but somehow it's now able to do that from python console.
pykd.dbgCommand("!analyze -v")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
pykd.DbgException: Call IDebugClient::GetOutputCallbacks failed
HRESULT 0x80010107
any help would be appreciated.
thanks to everyone answering in advance.
I tried to run dbgCommand('!analyze -v') with three different dump from python REPL:
usermode native dump: OK
kernel mode dump: OK
managed app dump:
0:000> !py
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> dbgCommand('analyze -v')
Traceback (most recent call last):
File "<console>", line 1, in <module>
pykd.DbgException: Call IDebugControl::ExecuteWide failed
HRESULT 0x80040205
Then I run this script:
import pykd
a = pykd.dbgCommand('!analyze -v')
print(a)
this script works OK with all of these dump.
I believe there is a bug. I've opened an issue:
https://githomelab.ru/pykd/pykd-ext/-/issues/15
Can you provide a dump which reproduce the bug to the pykd issues tracker.
According to the Python documentation of the zlib module, decompressobj objects have a copy() function to clone the decompressor's state. This equivalent functionality is also mentioned for the compressing side on StackOverflow here.
However, when I try to use it, it simply doesn't exist:
C:\>C:\Python27\python.exe
Python 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import zlib
>>> meow = zlib.decompressobj()
>>> purr = meow.copy()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: copy
Is this a bug in Python? I tried searching for this subject, but too many false hits get in the way.
Never mind. It's a known bug that was fixed in newer versions of 2.7. I just needed to check the bug list. For some reason, Google didn't index that bug page.
I'm trying to get started with Apache Spark. I'd like to use it via python. However, when I run pyspark from the command line I get the following error message:
C:\Programs\Apache\Spark\spark-1.2.0-bin-hadoop2.4\bin>pyspark.cmd
Running python with PYTHONPATH=C:\Programs\Apache\Spark\spark-1.2.0-bin-hadoop2.
4\bin\..\python\lib\py4j-0.8.2.1-src.zip;C:\Programs\Apache\Spark\spark-1.2.0-bi
n-hadoop2.4\bin\..\python;
Python 2.7.8 |Anaconda 2.1.0 (32-bit)| (default, Jul 2 2014, 15:13:35) [MSC v.1
500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
find: 'version': No such file or directory
else was unexpected at this time.
Traceback (most recent call last):
File "C:\Programs\Apache\Spark\spark-1.2.0-bin-hadoop2.4\bin\..\python\pyspark
\shell.py", line 45, in <module>
sc = SparkContext(appName="PySparkShell", pyFiles=add_files)
File "C:\Programs\Apache\Spark\spark-1.2.0-bin-hadoop2.4\python\pyspark\contex
t.py", line 102, in __init__
SparkContext._ensure_initialized(self, gateway=gateway)
File "C:\Programs\Apache\Spark\spark-1.2.0-bin-hadoop2.4\python\pyspark\contex
t.py", line 211, in _ensure_initialized
SparkContext._gateway = gateway or launch_gateway()
File "C:\Programs\Apache\Spark\spark-1.2.0-bin-hadoop2.4\python\pyspark\java_g
ateway.py", line 73, in launch_gateway
raise Exception(error_msg)
Exception: Launching GatewayServer failed with exit code 255!
Warning: Expected GatewayServer to output a port, but found no output.
When I try and run the scala interface by running spark-shell I get the message:
find: 'version': No such file or directory
else was unexpected at this time.
I cant find any info on this error online, other than
which turned out to be a dead end.
https://issues.apache.org/jira/browse/SPARK-3808
Please help!
I had the same problem in spark 1.2.0 but not in spark 1.0.2.
The reason was in my case that I had cygwin in the DOS classpath.
Spark uses the find command in the file 'spark-class2.cmd', which used then the cygwin find command instead of the DOS find command, which works somewhat different.
I removed cygwin from the DOS PATH, which solved the problem.
Regards, Felix
I am trying to utilize the python-iptables package to list iptables rules in a web app. When I add the iptc package to my environment, I get the below error. I used yum 'provides' to find where the libxtables.so.4 file comes from and found that the iptables and iptables-devel packages were the appropriate choice in CentOS 6.4 x64. I upgraded those packages but it did not change the error.
Does anyone have any suggestions about how I can resolve this?
pgrace#ny-misc01:~/repos/python-iptables/libxtwrapper$ python
Python 2.6.6 (r266:84292, Sep 11 2012, 08:34:23)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import iptc
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib64/python2.6/site-packages/iptc/__init__.py", line 10, in
from ip4tc import Table, Chain, Rule, Match, Target, Policy, IPTCError
File "/usr/lib64/python2.6/site-packages/iptc/ip4tc.py", line 11, in
from xtables import (XT_INV_PROTO, NFPROTO_IPV4, XTablesError, xtables,
File "/usr/lib64/python2.6/site-packages/iptc/xtables.py", line 744, in
class xtables(object):
File "/usr/lib64/python2.6/site-packages/iptc/xtables.py", line 757, in xtables
_xtables_afinfo = ct.c_void_p.in_dll(_lib_xtables, "afinfo")
ValueError: /lib64/libxtables.so.4: undefined symbol: afinfo
>>>
See this: https://github.com/ldx/python-iptables/issues/25
This is a known problem, old versions of libxtables declared afinfo as static, thus it is not accessible for python-iptables. There is a possible workaround, though - please keep an eye on the ticket, it will be updated as soon as there has been progress.
Another solution is to update iptables on your machine.
Disclaimer: I am the maintainer of python-iptables.
Update: this should be fixed now.
I'm trying to use generateDS under windows, which uses os.tmpfile. Unfortunately, os.tmpfile doesn't work for me:
(oneclickcos) C:\Users\Marcin\Documents\oneclickcos\xsd>python
Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.tmpfile()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 13] Permission denied
>>>
I've got all my temp directories set with full control for everyone, so that shouldn't be the problem.
What could be causing this?
Run the script as administrator (right click on the script and select 'run as administrator'), the script lacks the permissions to execute os.tmpfile().
Edit:
As I see you're using the interpreter, simply run the interpreter as administrator. If you're accessing it though a terminal, running the terminal as administrator should be sufficient.
As Griffin pointed out the problem is that the os.tmpfile() tries to create a file in the root directory. If you don't like to run the script as administrator you can use os.tmpnam() and handle the file yourself.
Warning: Use of tmpnam() is vulnerable to symlink attacks