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.
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).
Im working with Agilent IVI drivers in Python 2.7.9 and can't seem to get 'proven' code to work on a particular Windows 7 machine. It executes successfully on other machines.
While this issue seems rather limited to one instrument, it appears to be a broader Python issue, so I turn to Stack Overflow for help. Any help or insight would be great.
The following code
# Import the TLB
from comtypes.client import GetModule, CreateObject
GetModule('AgInfiniium.dll')
# Pull in the coefficients and classes, we'll need those
from comtypes.gen.AgilentInfiniiumLib import *
# Instantiate the driver
OScope = CreateObject('AgilentInfiniium.AgilentInfiniium')
# Make constants of our settings
Address = "TCPIP0::10.254.0.222::INSTR"
resetOScope = False
# Open a connection to the scope
OScope.Initialize(Address,False,resetOScope,'')
# Make a measurement
print OScope.Measurements.Item("Channel1").ReadWaveformMeasurement(
MeasFunction=AgilentInfiniiumMeasurementAmplitude, MaxTime=10)
yields the following error:
Traceback (most recent call last):
File "P:\Aperture\Validation\WMI_BGA_Board\TestMatrixCode\scopeTest2.py", line 29, in <module>
print OScope.Measurements.Item("Channel1").ReadWaveformMeasurement(MeasFunction=AgilentInfiniiumMeasurementAmplitude ,MaxTime=10)
File "C:\Python27\lib\site-packages\comtypes-1.1.0-py2.7.egg\comtypes\__init__.py", line 656, in call_with_inout
rescode = list(rescode)
TypeError: 'c_double' object is not iterable
In my limited debugging attempts, I have seen that this call_with_inout
function tries to convert my Python arguments into arguments for the following C++ function:
public void ReadWaveformMeasurement(
AgilentInfiniiumMeasurementEnum MeasFunction,
AgilentInfiniiumTimeOutEnum MaxTime,
ref double pMeasurement)
It's creating some kind of variable for the pMeasurement pointer that ends up being type c_double, and then complains that it's not iterable.
At this point, this seems like it's local to this machine. I've gone to the extent of uninstalling Python, reinstalling the Agilent driver, and trying two versions of comtypes (1.1.0 and 1.1.1). Yet the problem persists. Any ideas? Thanks.
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).
I'm trying to use python-gdl (python bindings for gdl library, which features some docking windows for gtk+2). Even the origianl C gdl itself is awfully documented; its python bindings seems very unstable. Could you suggest any sample program, written in python-gdl and working?
I've tried to use the one described here and here, but it would fail with ugly:
Traceback (most recent call last):
File "gdl_test.py", line 17, in <module>
item1 = gdl.DockItem('item1', 'Item 1', gtk.STOCK_OPEN, gdl.DOCK_ITEM_BEH_NORMAL)
TypeError: Gdl.DockItem.__init__() takes at most 3 arguments (4 given)
The python bindings don't even seem to provide the constructor signatures: e.g.
>>> help(gdl.DockItem.__init__)
Help on wrapper_descriptor:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
>>> help(gdl.DockItem.__doc__)
no Python documentation found for "Object GdlDockItem\n\nSignals from GdlDockItem:\n dock-drag-begin ()\n dock-drag-motion (gint, gint)\n dock-drag-end (gboolean)\n selected ()\n\nProperties from GdlDockItem:\n orientation -> GtkOrientation: Orientation\n
...more bloody mess here...
Is this project completely dead and just deceives naive programmers with false promises?