BadOptionError when import volatility.conf - python

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).

Related

cusolver library not found

I am trying to use skcuda in my python code but whenever i want to use it, it rises the following exception:
Traceback (most recent call last):
File "/home/rohola/Projects/Python/wordnetwork/s.py", line 6, in <module>
from skcuda import cusolver
File "/home/rohola/anaconda3/lib/python3.4/site- packages/skcuda/cusolver.py", line 51, in <module>
raise OSError('cusolver library not found')
OSError: cusolver library not found
i was just tried to use skcuda
from skcuda import cusolver
handle = cusolver.cusolverDnCreate()
i installed pycuda, NVIDIA CUDA Toolkit. What's wrong about my code or dependencies?
import ctypes
a = ctypes.cdll.LoadLibrary( "/usr/local/cuda-8.0/targets/x86_64-linux/lib/libcusolver.so" )
gets me
OSError: /usr/local/cuda-8.0/targets/x86_64-linux/lib/libcusolver.so: undefined symbol: GOMP_critical_end
which seems to be a yet unsolved issue according to this github thread
Though, a 7.5 version which
/usr/lib/x86_64-linux-gnu/libcusolver.so
seems to point to works well. And author's fix seems to work with it.
I finally found a solution to my problem. Firstly, i searched for libcusolver.so with
locate libcusolver.so
and then changed the following code in cusolver.py from:
_libcusolver = ctypes.cdll.LoadLibrary(_libcusolver_libname)
to:
_libcusolver = ctypes.cdll.LoadLibrary("/usr/local/cuda-7.5/targets/x86_64-linux/lib/"+_libcusolver_libname)
now the following code:
from skcuda import cusolver
handle = cusolver.cusolverDnCreate()
works without any error.
UPDATE:
If you have installed cuda8.0 or 9.0 the best way to solve the problem is to find this line in cusolver.py:
_libcusolver = ctypes.cdll.LoadLibrary(_libcusolver_libname)
and add this line before it:
ctypes.CDLL('libgomp.so.1', mode=ctypes.RTLD_GLOBAL)
You have to make sure that you already installed libgomp.

Strange import error in Emscripten cross-compiled CPython

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.

Grail (web browser) installation on Scientific Linux

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.

pymc.NormApprox unexpected behavior - unable to see mu and C and nuking of namespace

I am new to pymc and enjoying it but have run into some very strange behavior. I want to use it to track something moving; following the tutorials I set up some stochastics and attempted to use pymc.NormApprox() on it. fit() seems to run but when I try to get the output out it gives me KeyError. When I switch to using pymc.MCMC it runs `sample() OK but then nukes the namespace (Python even forgets how to exit()).
System: Ubuntu 12.04, scipy numpy etc installed, pymc installed via easy_install; also tried from git.
Code to reproduce:
test.py::
import pymc
import numpy as np
x = pymc.MvNormal('x',mu=np.zeros(4),tau=np.eye(4))
#pymc.deterministic()
def y(x=x):
out = np.zeros(2)
out[0] = x[0]+x[2]
out[1] = x[1]+x[3]
return out
ymeas = pymc.MvNormal('ymeas',mu=y,tau=np.eye(2)*100000,value=20*np.ones(2),observed=True)
Then, in a shell running python or ipython::
import test
import pymc
foo = pymc.NormApprox(test)
foo.fit()
foo.mu[foo.x] # Fails - gives KeyError
foo._mu # I can see it OK if I break privacy rules
foo = pymc.MCMC(test)
foo.sample(10000) # runs OK
foo # fails - namespace is nuked
What I expect to see:
foo.mu[foo.x] should give me the normal approx to the posterior; I shouldn't get a Key error and shouldn't have to break into foo._mu
instead I get:
>>> foo.mu[foo.x]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/pymc-2.2-py2.7-linux-x86_64.egg/pymc/NormalApproximation.py", line 56, in __getitem__
tot_len += self.owner.stochastic_len[p]
KeyError: 9.9999517411499177
>>> foo._mu
array([ 9.99995174, 9.99997163, 10.0000485 , 10.00002837])
>>>
Also I noticed that the docstring for foo.mu says N.mu(p1,p2) but the online documentation says N.mu[N.p1,N.p2].
As for the post- MCMC namespace meltdown, it even forgets how to exit()
Also I can confirm that I get the same problem on a different machine (MacBook Pro) running a different installation (Enthought Python).

Pymacs - Unable to call a method obtained with pymacs-eval

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.

Categories