The Pymacs 0.25 manual has the following snippet in Section 3.4.2
(pymacs-exec "import re")
(setq matcher (pymacs-eval "re.compile('PATTERN').match"))
(pymacs-call matcher "PATTERN123")
In Emacs24.2 on Ubuntu 12.04 (32-bit) with Python 2.7.3, the first two statements execute fine, but the third one throws the following error:
pymacs-report-error: Python: Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/Pymacs.py", line 268, in loop
value = eval(text)
File "<string>", line 1
(lambda (&rest arguments) (pymacs-apply (quote (pymacs-python . 5)) arguments))(".")
I don't know a lot of Elisp, but the lambda statement itself evaluates without any errors with C-x C-e, so I don't know what's going wrong. Also, looking at Pymacs.py, it looks like the code is trying to directly eval elisp code. Please help?
Since the pymacs-call statement returns a lambda function, calling it with (funcall matcher "PATTERN123") works as expected. It's possible that the sample code in the manual might be wrong.
Related
the version of python is 3.6
I tried to execute my code but, there are still some errors as below:
Traceback (most recent call last):
File
"C:\Users\tmdgu\Desktop\NLP-master1\NLP-master\Ontology_Construction.py",
line 55, in
, binary=True)
File "E:\Program
Files\Python\Python35-32\lib\site-packages\gensim\models\word2vec.py",
line 1282, in load_word2vec_format
raise DeprecationWarning("Deprecated. Use gensim.models.KeyedVectors.load_word2vec_format instead.")
DeprecationWarning: Deprecated. Use
gensim.models.KeyedVectors.load_word2vec_format instead.
how to fix the code? or is the path to data wrong?
This is just a warning, not a fatal error. Your code likely still works.
"Deprecation" means a function's use has been marked by the authors as no longer encouraged.
The function typically still works, but may not for much longer – becoming unreliable or unavailable in some future library release. Often, there's a newer, more-preferred way to do the same thing, so you don't trigger the warning message.
Your warning message points you at the now-preferred way to load word-vectors of that format: use KeyedVectors.load_word2vec_format() instead.
Did you try using that, instead of whatever line of code (not shown in your question) that you were trying before seeing the warning?
I write below code and it gives me error in first line! whats wrong is with this code:
import volatility.conf as conf
import volatility.registry as reg
import volatility.commands as commands
import volatility.addrspace as addrspace
import volatility.plugins.taskmods as taskmode
# configure volatility
reg.PluginImporter()
config=conf.ConfObject()
reg.register_global_options(conf,commands.Command)
reg.register_global_options(conf,addrspace.BaseAddressSpace)
config.parse_options()
config.PROFILE="Linuxfedora32x64"
config.LOCATION="./dumps/mem.lime"
p=taskmode.PSList(config)
for process in p.calculate:
print(process)
the error code:i think there is some code insode conf.py witch in not support in python 3.6 .but volatility is copatible with python 3.6. so i don't know what to do :
Traceback (most recent call last):
File "../PycharmProjects/volpractive/test.py", line 6, in <module>
import volatility.conf as conf
File "/anaconda3/lib/python3.6/site-packages/volatility-2.6-py3.6.egg/volatility/conf.py", line 84
except (optparse.BadOptionError, optparse.OptionValueError), err:
You were right, the line:
except (optparse.BadOptionError, optparse.OptionValueError), err:
is not Python3 compatible (according to [Python]: The try statement).
According to [GitHub]: volatilityfoundation/volatility - (2.6) volatility/README.txt:126+ (as it is at this point):
Requirements
============
- Python 2.6 or later, but not 3.0. http://www.python.org
Note:
The stacktrace is still incomplete (missing the last line - should be SyntaxError); that would have cleared things up much sooner
So, you have to run it with Python2.6+ (of course you could also modify the code (at least the part that you need) to be Python3 compatible, but I doubt that's feasible).
I am porting CPython to Emscripten, and it builds successfully. However, when I try to run the python.asm.js through Node.js, I get a very strange error inside the Py_InitializeEx(0) call:
Traceback (most recent call last):
File "/lib/python2.7/site.py", line 62, in <module>
import os
File "/lib/python2.7/os.py", line 44, in <module>
from posix import *
TypeError: 'NotImplementedType' object does not support indexing
The error is generated from PySequence_GetItem in Objects/abstract.c, but I don't understand how the execution gets there. If I do import posix before the line that causes the error, the import posix statement finish successfully, and I can call functions in the posix module. Thus, the error is related to from <module> import * line. How is PySequence_GetItem related to from <module> import * statement, and what could be the reasons for the error?
If you want to reproduce the problem, I released the code on GitHub
While investigating what is going wrong, I switched off the optimization (compiled and linked with -O0). The resulting JS executable also failed, but with a different error:
Invalid function pointer '495' called with signature 'iii'. Perhaps this is
an invalid value (e.g. caused by calling a virtual method on a NULL pointer)?
Or calling a function with an incorrect type, which will fail? (it is worth
building your source files with -Werror (warnings are errors), as warnings can
indicate undefined behavior which can cause this)
This pointer might make sense in another type signature:
ii: _dict_keys iiii: 0 i: undefined iiiii: 0 viii: 0 vii: 0 vi: 0 v: 0
495
495
I looked through Emscripten's settings.js for options related to function pointers, and found EMULATE_FUNCTION_POINTER_CASTS which fixed the problem.
I currently am trying to use
paraview.simple.Histogram(Input, params)
as
paraview.simple.Histogram(q, BinCount = 30)
in the shell where q is a variable data set from my "out.e" ExodusII file. I'm getting the error
Traceback (most recent call last):
File "<console>", line 1, in <module>
NameError: name 'q' is not defined
I've tried to search the literature on python shell scripting in Paraview but it seems to be eluding me. I know this is a quick fix. Thanks
Try this instead:
Histogram(SelectInputArray="q", BinCount=30)
This assumes you currently have the reader as the active object in the Pipeline browser.
I was able to answer this problem using the following.
outset = Reader(FileName=['/dir/out.e'])
and for the Histogram
histogram1_1 = Histogram(Input=outset)
histogram1_1.SelectInputArray = ['CELLS', 'q']
histogram1_1.BinCount = 30
Note for anyone who comes into this issue, the TRACE option in the Python Shell will build a script for you when you do anything in the GUI.
I'm not sure if Grail browser is a good choice nowadays, however I want to try it, because I have some problems about graphics running on Firefox-Fermi. The next, is what I obtain after trying grail-0.6 (tgz)
# python grail.py
Traceback (most recent call last):
File "grail.py", line 43, in ?
from Tkinter import *
After installing "tkinter" adequately, I run "grail.py" again, and I get
# python grail.py
/root/grail-0.6/grailbase/app.py:6: Deprecation Warning: the regex module is
deprecated; please use the re module
import regex
/usr/lib/python2.4/regsub.py:15: DeprecationWarning: the regsub module is
deprecated; please use re.sub()
DeprecationWarning)
Traceback (most recent call last):
File "grail.py", line 499, in ?
main()
File "grail.py", line 108, in main
app = Application(prefs=prefs, display=display)
File "grail.py", line 248, in __init__
self.stylesheet = Stylesheet.Stylesheet(self.prefs)
File "/root/grail-0.6/Stylesheet.py", line 21, in __init__
self.load()
File "/root/grail-0.6/Stylesheet.py", line 45, in load
massaged.append((g, c), v % fparms_dict)
TypeError: append() takes exactly one argument (2 given)
but now, I'm not able to understand the message at all. May you advice me about this problem?
Wow - that's a blast from the past! My advice is to give up: Grail hasn't been touched in more than a dozen years. It's dead.
The error message you're getting stems from a change made way back in Python 1.6 (released 5 September 2000). Here's the message from the release notes:
The append() method for lists can no longer be invoked with more
than one argument. This used to append a single tuple made out of
all arguments, but was undocumented. To append a tuple, use
e.g. l.append((a, b, c)).
So, you can:
Give up. Recommended ;-)
Install an ancient version of Python; or,
Change that line to
massaged.append(((g, c), v % fparms_dict))
and see what breaks next ;-)
About the next problem
Python 0.9.1 is extremely old, from early 1991. The language changed in many, many ways before 1.0 was released.
According to the old Grail home page, Grail 0.6:
requires Python 1.5 or newer, and Tcl/Tk 8.0 or newer.
So find Python 1.5 if you're determined to pursue this ;-) Note that the .append() semantics were changed in version 1.6, so the original .append() code that hurt you at first should still work OK in 1.5.