I am trying to use NetworkX 1.8.1 with Ironpython 2.7. Now I've been stuck to this problem for about 12 hours so far.... but without any luck. Whenever I tried to import networkX, I am having 'non implemented' error as below:
NotImplementedError: The method or operation is not implemented. File
"C:\Program Files (x86)\IronPython
2.7\lib\site-packages\networkx\algorithms\isomorphism\matchhelpers.py",
line 23, in copyfunc return types.FunctionType(f.func_code,
f.func_globals, name or f.name, .....
I tested networkx 1.6, but the same result. It seems that there are some problems in line 23 of matchhelpers.py, but I could never figured it out. Can anyone look into this problem? I am so desperate.....
(And also please recommend me any alternative Graph libraries compatible with IronPython)
Thanks!
This appears to be a bug in IronPython - types.FunctionType resolves to a constructor call that throws a NotImplementedException (see https://github.com/IronLanguages/main/blob/master/Languages/IronPython/IronPython/Runtime/PythonFunction.cs#L72).
It's old code, so I'm not sure why it does that. I've opened issue #35180 to track it.
Related
I'm trying to use pyFirmata, but I can't get it to work. Even the most basic of the library does not work. I guess there is something wrong with the library code.
from pyfirmata import Arduino,util
import time
port = 'COM5'
board = Arduino(port)
I get this error:
Traceback (most recent call last):
File "c:\Users\Public\pythonpublic\arduino.py", line 5, in <module>
board = Arduino(port)
^^^^^^^^^^^^^
File "C:\Users\marce\AppData\Roaming\Python\Python311\site-packages\pyfirmata\__init__.py", line 19, in __init__
super(Arduino, self).__init__(*args, **kwargs)
File "C:\Users\marce\AppData\Roaming\Python\Python311\site-packages\pyfirmata\pyfirmata.py", line 101, in __init__
self.setup_layout(layout)
File "C:\Users\marce\AppData\Roaming\Python\Python311\site-packages\pyfirmata\pyfirmata.py", line 157, in setup_layout
self._set_default_handlers()
File "C:\Users\marce\AppData\Roaming\Python\Python311\site-packages\pyfirmata\pyfirmata.py", line 161, in _set_default_handlers
self.add_cmd_handler(ANALOG_MESSAGE, self._handle_analog_message)
File "C:\Users\marce\AppData\Roaming\Python\Python311\site-packages\pyfirmata\pyfirmata.py", line 185, in add_cmd_handler
len_args = len(inspect.getargspec(func)[0])
^^^^^^^^^^^^^^^^^^
AttributeError: module 'inspect' has no attribute 'getargspec'. Did you mean: 'getargs'?
As already pointed out in another answer, the pyFirmata modules is currently documented to run on Python 2.7, 3.6 and 3.7. This doesn't mean it won't work on other versions, but probably that it hasn't been tested on other versions by the author and it isn't officially supported. So it may or may not work on newer Python versions.
Your error message is caused by a missing function inspect.getargspec(). This function is part of the Python Standard Library, but has been deprecated since Python 3.0 (which came out in 2008). Unfortunately the author wasn't aware of this or simply didn't bother to fix it, so now the code doesn't work anymore with the latest version of Python.
In the Python documentation, you can see that the function is still available in version 3.10, but not in version 3.11.
To solve this you have a number of options:
Downgrade to Python 3.10, which is currently still a good option (Python 3.10 is "alive" until 2026-10-04). I don't know if all other functionality does work. I guess it will, but you would have to find out yourself.
Downgrade to Python 3.7, which is claimed to be supported. Given that Python 3.7 is also still alive (until 2023-06-27), that's a reasonable option as well.
Create an issue for the pyFirmata module and hope the author will fix the problem. Note that an issue has already been created by someone in 2019 but apparently without effect. You could leave a comment there confirming that this has now broken for real.
Clone the library and fix it yourself (and create a Pull Request to get it in the official library).
Find another, similar, library that does work with Python 3.11.
Write the code yourself.
Downgrading to a Python version between 3.7 and 3.10 is certainly the simplest option, and leaving some feedback to the author will give you a chance it will be fixed in the future, in case your planning to use your script for a longer time.
According to the first line of pyFirmata docs:
It runs on Python 2.7, 3.6 and 3.7
You are using Python 3.11. The inspect (core library module) has changed since Python 3.7.
I have just gotten a new computer and I had to reinstall anaconda (python version 3.7.3) and I am getting the following error when I execute commands. There does not seem to be any specific commands that it happens with, I can't correlate it with any one module.
C:\ProgramData\Anaconda3\lib\site-packages\ipykernel\ipkernel.py:448: DeprecationWarning: `input_splitter` is deprecated since IPython 7.0, prefer `input_transformer_manager`.
status, indent_spaces = self.shell.input_splitter.check_complete(code)
After searching online, it seems like one of my dependencies might be causing this. At first I thought it was geopandas or numpy but i don't think it is. I am relatively new to python so if anyone has any advice on how to solve this, that would be great.
thanks
I have Python 3.9.1 with numpy 1.19.4 install, and Maya 2020. I have installed a plug-in (SMPL, actually, from here: https://smpl.is.tue.mpg.de/downloads), loads without any problems, but errors when it hits the first line that actually references numpy ('''np.array()'''...) with the error being this:
'module' object has no attribute 'array'
I suspect I may be using a version of numpy that Maya does not like. Has anybody else come across this? Any hints on how to resolve would be most welcome. Thanks!
OK, solved! Thanks #mad-physicist for nudging me towards the correct direction.
The issue boiled down to requiring a maya-compatible build of numpy, to be pip-installed under the specific python instance (mayapy.exe) that ships with the Maya installation.
The details here: https://forums.autodesk.com/t5/maya-programming/numpy-2018-2019/td-p/9349010
It is supposed to be for Maya 2018 and 2019, but it worked just fine with my 2020 installation too.
I am attempting to use the PyMultinest package. The full error text I am encountering is AttributeError:dlsym(RTLD_DEFAULT, run): symbol not found in the __getitem__() function in ctypes/__init__.py. I'll include more text and code below, but I am mostly trying to understand what this error is telling me - my Google Fu is apparently lacking, and the StackExchange questions I have seen relating to this error seem to be hyper-focused on solving a specific instance of this error. So - What is this error trying to tell me is wrong?
More context. I attempt to execute the PyMultinest (PMN) package as directed in the PMN documentation. PMN is, effectively, a Python wrapper for a C program. Running PMN requires a fair bit of setup code (several ancillary functions need to be defined, as well as a host of variables), which I'm not including here by default because it's ... a lot, but I can if needed. The PMN execution line I use is
pmn.run(Loglike, Prior, ndims, n_live_points=1000, n_params=n_params, outputfiles_basename='./'+ProjectName+'/temp_', resume=False, verbose=True)
This returns the error traceback
File "[redacted]", line 139, in <module>
pmn.run(Loglike, Prior, ndims, n_live_points=1000, n_params=n_params, outputfiles_basename='./'+ProjectName+'/temp_', resume=False, verbose=True)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pymultinest/run.py", line 254, in run
lib.run(*args_converted)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ctypes/__init__.py", line 386, in __getattr__
func = self.__getitem__(name)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ctypes/__init__.py", line 386, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(RTLD_DEFAULT, run): symbol not found
If it helps, I have determined that the name variable being passeed through self.__getitem__(), and thus into self._FuncPtr(), is run. Although, that might be obvious looking at the AttributeError message.
I am running Python 3.8 (as shown above) on a MacOS machine. Last summer, I was able to execute PMN on this machine using extremely similar code to that which I am using now. I am currently trying to optimize my code from last summer, which is why I'm surprised it isn't simply "working".
So far my attempts at fixing this have been mostly centered on reinstalling PMN. I have done a clean install (pip uninstall/pip install) of the PMN package, as well as following the PMN documentation to rebuild the C portion of the package. I have included the source directories of the C software in my Path variables - or at least, I tried to, I am assuming I was successful, but I'm not very familiar with Macs.
Ultimately, I just wish I understood what Python was telling me with this error better. It would help me direct my own attempts at solving the issue. I suspect it is saying "We don't know where to find this 'run' command you're asking for," in which case I need to figure out why my Path variable changes aren't working. Am I on the right path?
Some hints how to resolve this are given in these issues:
https://github.com/JohannesBuchner/PyMultiNest/issues/160
https://github.com/JohannesBuchner/PyMultiNest/issues/163
It is important to cleanly recompile (empty build folder) when the environment changes, so that cmake recognises changed libraries and compilers.
Check if you are running everything with python3 and not python (works as python 2.x is you have both version 2 and 3 installed)
Check is all the PyMultiNest python files are rewritten in python 3 style, e.g. $ print "something" becomes $ print("something")
My supervisor was accidentally running on python 2.7 and got the same error, so your error might as well be due to mismatch of python version usages.
Run command flutter pub cache clean and flutter clean and after that run flutter pub get now relaunch your emulator it worked for me.
I installed trepan3k with pip3 install trepan3k and I want to debug a file with trepan3k main.py, but I'm getting this error:
Traceback (most recent call last):
File "/usr/local/bin/trepan3k", line 10, in <module>
sys.exit(main())
File "/usr/local/lib/python3.7/site-packages/trepan/cli.py", line 212, in main
normal_termination = dbg.run_script(mainpyfile)
File "/usr/local/lib/python3.7/site-packages/trepan/debugger.py", line 217, in run_script
exec(compiled, globals_, locals_)
...
File "/usr/local/lib/python3.7/site-packages/pygments/formatters/terminal.py", line 101, in format
return Formatter.format(self, tokensource, outfile)
File "/usr/local/lib/python3.7/site-packages/pygments/formatter.py", line 95, in format
return self.format_unencoded(tokensource, outfile)
File "/usr/local/lib/python3.7/site-packages/pygments/formatters/terminal.py", line 126, in format_unencoded
outfile.write(ansiformat(color, line.rstrip('\n')))
File "/usr/local/lib/python3.7/site-packages/pygments/console.py", line 68, in ansiformat
result.append(codes[attr])
KeyError: 'darkblue'
Uncaught exception. Entering post-mortem debugger...
trepan3k: That's all, folks...
This happens on macOS Mojave as well as Ubuntu 18.04. What is going on and what can I do to debug with trepan?
Upgrade trepan3k to version 0.8.9 that I just released and I think you will be fine.
Longer story. I am sorry I didn't see this earlier. As a big user of trepan3k myself, I had noticed this a while ago and had been working around it by using previously installed versions of trepan3k. Since I wasn't aware of anyone else noticing this, I didn't think to investigate, let alone fix it.
Then at some point I had some free time, and did investigate. The longer answer is that there seems to have been an update to Pygments after 2.2.0 that is incompatible and color names are different.
I wish I understood in more detail what's going on in Pygments. I suspect it has to do with using a reduced set of color names and handling dark and light backgrounds in a way that doesn't mess things up when you switch between dark and light.
If there is someone out there that knows and would elucidate I'd be grateful. And bonus points if you know exactly how change Pygments to a version after 2.2.0.
The relevant code that trepan uses for working with Pygments is https://github.com/rocky/python3-trepan/blob/master/trepan/lib/format.py
I had to write a custom formatter for RsT to console. I had offered this to the Pygments community, but they decided that this shouldn't be in Pygments, but it was fine to have it in trepan3k the way it is.
This is one small example of the extra work you find in this debugger that aren't in the others in order to support a better user experience. Deparsing to show exact location is another example. But that means of course there's more possibility of breakage when packages do an incompatible upgrade.
So the final two takeaways.
If there's a bug in trepan3k, please report it in its issue tracker: https://github.com/rocky/python3-trepan/issues/new. I am more likely to see this there than as a Stack Overflow question.
If you haven't already, upvote the project. I use Github ratings to help guide me to know what work on when I have free time.