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.
Related
When I launch Anaconda Prompt I get the following error message:
Fatal Python error: init_import_site: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
File "C:\Users\USER\anaconda3\lib\site.py", line 589, in <module>
File "C:\Users\USER\anaconda3\lib\site.py", line 576, in main
File "C:\Users\USER\anaconda3\lib\site.py", line 359, in addsitepackages
File "C:\Users\USER\anaconda3\lib\site.py", line 208, in addsitedir
File "C:\Users\USER\anaconda3\lib\site.py", line 164, in addpackage
OSError: [Errno 9] Bad file descriptor
I am aware of very similar post but still I have not managed to solve this issue.
The anaconda had been working fine until a week ago and I haven't coded since then. When I tried to get back to it, anaconda navigator won't open and when I launch Anaconda Prompt (or try to run any code via visual studio code) this happens.
I have not created any file that has weird name recently (which seems to be one of common reasons for this problem) so I am very stuck.
So first thing I tried was trying the answers from above post (and more but they seemed irrelevant/infeasible since I can't access any of the conda-related commands at the moment)
One key problem seems to be having multiple versions of python used in one machine and I am 'almost' free from this issue since I have only used python that comes from conda in this laptop. I have used multiple versions in different environments of conda but this should not be an issue? Especially after I have reinstalled anaconda.
Even after reinstalling anaconda same problems persists. (Tried deleting properly following some of the answers also)
Just to add I am using windows 10 so some of the suggestions that were made in the previous post had not been applicable. My colleagues suggests the problem was caused by windows update but not certain.
Any suggestion would be much appreciated
it's not really an answer, not really a comment either (so don't accept this answer as is, it provides nothing but links)
Are you on Windows? have you seen the github issues page for Anaconda? This appers to be someone else with your problem: https://github.com/ContinuumIO/anaconda-issues/issues/11949
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 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 have used Inkscape and Latex extensively before. However I had to recently reinstall OS and all softwares I need on my computer. It is Linux Mint 18.3 Cinnamon now.
I am unable to render simple latex formula in Inkscape 0.92.2. The Ghostscript version I have is 9.18, and Texlive 2017 full installation. The error that I am getting is linked below. I will appreciate any help on this. Thank you!
Inkscape_Latex_Error
" Traceback (most recent call last):
File "eqtexsvg.py", line 160, in <module>
e.affect()
File "/usr/share/inkscape/extensions/inkex.py", line 285, in affect
self.output()
File "/usr/share/inkscape/extensions/inkex.py", line 272, in output
self.document.write(sys.stdout)
File "src/lxml/etree.pyx", line 2050, in lxml.etree._ElementTree.write
(src/lxml/etree.c:67059)
File "src/lxml/serializer.pxi", line 731, in lxml.etree._tofilelike
(src/lxml/etree.c:141721)
File "src/lxml/etree.pyx", line 326, in
lxml.etree._ExceptionContext._raise_if_stored (src/lxml/etree.c:13244)
File "src/lxml/serializer.pxi", line 648, in
lxml.etree._FilelikeWriter.write (src/lxml/etree.c:140348)
TypeError: write() argument must be str, not bytes"
Let me give you the solution first that worked for me. I was having the same problem with Inkscape 0.92.2. If you are not very specific about using the latest version of Inkscape then just uninstall 0.92.2 and install version 0.91.7. It will solve your problem. I am using Ubuntu 16.04. In the software center both these versions are available. But initially, I also chose 0.92.2 and started having the same problem. Then I uninstalled it and installed the older version. Latex rendering is working perfectly now. Just one thing, before doing anything else, check whether you have "pstoedit" installed or not. If not, do it first.
I understand why 0.92.2 is not working on Ubuntu 16.04 or for your system. Inskscape uses the python script "eqtexsvg.py" to convert tex equations to svg format. This process obviously require the python script to find the path of latex command. When you install 0.91.7 you will see Inkscape gets installed in /usr/share directory. But 0.92.2 uses /home/user/snap directory. Hence, the .inx part of the extension can neither find latex nor dvips. I think the problem with 0.92.2 can be solved as well just by mentioning the full path of latex and dvips in the .inx file. I was too lazy to do that. Anyway, 0.91.7 is pretty good enough at this moment for me. I may try the other solution later.
I'm really having trouble getting to the first rung of the Sphinx tutorial ladder.
I need to implement Sphinx for work projects. We are starting fresh with a new code-base (Django) for a large project.
I've been tasked with setting up our new code-base (automated unit tests, documentation, etc). I've used doxygen in the past (mostly for C++ and a bit for Python). I've read a lot of sources saying Sphinx is the best for Python and I'd like to give it a try.
The problem is that I can't even seem to get through the first step of the tutorial - sphinx-quickstart.
I am able to tab-complete the command so I assume it's installed correctly. (maybe not?)
Here is the error I get:
File "/usr/local/bin/sphinx-quickstart", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 2655, in <module>
working_set.require(__requires__)
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 648, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 546, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: docutils>=0.7
I've tried to find some online info related to this problem but I haven't been able to find anything useful.
Any suggestions?
Looks like you are missing docutils, or you have an older version;
pkg_resources.DistributionNotFound: docutils>=0.7
Are you sure it's installed?
Try:
pip install --force-reinstall sphinx
It looks like the Sphinx package was not correctly installer or, more correctly, it's dependencies are not currently installed. If you do not have super-user privilege, then find an administrator to install or use virtualenv instead.
I highly recommend using virtualenv whenever possible since it does not touch the stuff in /usr/local or any of the Python .../site-packages directories. I will warn you that it is rather addictive :-)