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.
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 work with the openai gym module but I get this error:
>>> import atari_py
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\ssit5\AppData\Local\Programs\Python\Python38\lib\site-packages\atari_py\__init__.py", line 1, in <module>
from .ale_python_interface import *
File "C:\Users\ssit5\AppData\Local\Programs\Python\Python38\lib\site-packages\atari_py\ale_python_interface.py", line 17, in <module>
ale_lib = cdll.LoadLibrary(os.path.join(os.path.dirname(__file__),
File "C:\Users\ssit5\AppData\Local\Programs\Python\Python38\lib\ctypes\__init__.py", line 451, in LoadLibrary
return self._dlltype(name)
File "C:\Users\ssit5\AppData\Local\Programs\Python\Python38\lib\ctypes\__init__.py", line 373, in __init__
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\Users\ssit5\AppData\Local\Programs\Python\Python38\lib\site-packages\atari_py\ale_interface\ale_c.dll' (or one of its dependencies). Try using the full path with constructor syntax.
I don't have an ale_c.dll and tried finding solutions but nothing worked.
I followed the solution here https://github.com/openai/gym/issues/1726 but when trying to import atari_py it comes up with the same error. I don't see why the __init__ would search for something that didn't come with the module either. There were other StackOverflow questions that I looked at but they also yielded no results. The only solution I can think of is to get a copy of ale_c.dll but I don't know how I would get it.
I was facing the same error. Fortunately, I was able to find one workaround. Follow this steps and you should be good to go.
Download ale_c.dll from here.
Copy it in C:\Users\Deep Raval\AppData\Local\Programs\Python\Python38\Lib\site-packages\atari_py\ale_interface (Your path can be different).
Try to download arari-py package from conda
conda install -c conda-forge atari_py
this will fix your problem even if you are using Python > 3.7
For anybody else in the future, my problem was that I got the same error but I already had the ale_c.dll file in the right folder.
I followed a solution on this link --> https://github.com/openai/gym/issues/1726
I have tried to make it work with python 3.8 and 3.9 on Windows 10. Installing Python 3.7 and using it as the Python Interpreter on PyCharm resolved the issue. I have searched for the missing file while having 3.8 + version of Python and it did not exist at all. Atari-py is supported only for Python 3.7 (https://github.com/openai/atari-py) so having a higher version of that would not work. It is a bad idea to download files from unlicensed places so I advise you to install the supported version of Python (3.5, 3.6, and 3.7). Even though gym can work on 3.9 the atari version will not.
Just an update because gym 0.21.0 came out which supports ale-py and no longer uses atari-py (so any game marked v0 - v4 will no longer work if you use gym 0.21.0 and ale-py (which is supposed to come with gym). Make sure when you install your libraries that they are actually compatible.
Link to new version of gym https://brosa.ca/blog/ale-release-v0.7. When running v5 I do manage to render the game but I cannot find the other supported games. If you use gym 0.21.0 you will not need atari-py (atari_py).
From the example:
import gym
env = gym.make('ALE/Breakout-v5',
obs_type='rgb', # ram | rgb | grayscale
frameskip=5, # frame skip
mode=0, # game mode, see Machado et al. 2018
difficulty=0, # game difficulty, see Machado et al. 2018
repeat_action_probability=0.25, # Sticky action probability
full_action_space=True, # Use all actions
render_mode=None # None | human | rgb_array
)
it does actually run but the game is broken even in older versions of gym.
What I managed to get working after trying various python, gym and atari-py versions is:
I would suggest to the downloade the wheel file for you Windows and Python version from here: https://pypi.org/simple/atari-py/
and then execute pip install on this file like:
pip install atari_py-0.2.9-cp39-cp39-win_amd64.whl
This one helped for me (solution from github seems much much better, but it was not working for me - maybe because of venv? ) - for me it's a more safe solution than downloading a .dll from google drive.
This is a problem that you may face when using Windows.
Uninstall and reinstall atari using:
pip install -f https://github.com/Kojoley/atari-py/releases atari_py
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.
I have only recently started using Python 3.5 on my mac, which is running Yosemite, and I am trying to use the module networkx to compile and generate some visuals for graphics/network models. I don't have all that much programming experience so I apologise if I leave out any details.
I have successfully installed networkx (am able to use commands therefrom) but am currently struggling to install one of the optional modules that facilitates the generations of plots: GraphViz. I tried to install GraphViz via running through the command prompt the setup.py install commands but GraphViz installation seemingly requires another module, PyDot (PyDot2 to be more specific: pydot2-1.0.33-py3.5.egg.info). Therein lies the problem because I cannot seem to get PyDot to work correctly - I keep getting the following error when running the networkx command that uses PyDot (test2.py is a test graphics model):
Traceback (most recent call last):
File "/Users/mainuser/Downloads/test2.py", line 6, in <module>
nx.draw_graphviz(G)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/networkx/drawing/nx_pylab.py", line 982, in draw_graphviz
pos = nx.drawing.graphviz_layout(G, prog)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/networkx/drawing/nx_pydot.py", line 257, in graphviz_layout
return pydot_layout(G=G,prog=prog,root=root,**kwds)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/networkx/drawing/nx_pydot.py", line 277, in pydot_layout
D=P.create_dot(prog=prog)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pydot.py", line 1802, in <lambda>
lambda f=frmt, prog=self.prog : self.create(format=f, prog=prog))
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pydot.py", line 1966, in create
self.write(tmp_name)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pydot.py", line 1895, in write
dot_fd = file(path, "w+b")
NameError: name 'file' is not defined
After doing some research and playing around I feel like the issue is that the version of PyDot that I installed is not compatible with Python 3.5. However, I don't understand how this could be the case since I installed PyDot2 which says explicitly that it is compatible with Python 3+.
Any insight or directions would be much appreciated!
I noticed this issue and published a Python 3 compatible version on PyPi. The reason is that pydot/pydot2 uses functionalities that is removed in Python 3 already.
For Linux systems for Python 3.x, try:
pip3 install pydot3
Or in general for Python 2.x, try:
pip install pydot3
I'm getting this error every time I run any python file in Eclipse using PyDev:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/site.py", line 73, in <module>
__boot()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/site.py", line 2, in __boot
import sys, imp, os, os.path
ImportError: Bad magic number in /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/os.pyc
I'm using python 2.6. This problem does not occur when I run python from the terminal (2.7 or 2.6). The only substantial thing I've changed since everything last worked, is an update to OSX Lion from Snow Leopard.
Similar discussions to this seem to suggest some kind of removal of the .pyc file, because of some kind of mismatch between what was originally using the .pyc files (I'm not entirely sure what a magic number is...). But I was a bit cautious of the idea of deleting os.pyc from the Frameworks directory. When the only other file is an os.pyo file (not sure what the difference it), rather than an os.py.
I've installed all OSX Lion updates, Eclipse updates and PyDev updates.
This problem occurs even with code such as :
if __name__ == '__main__':
pass
Any help resolving this would be appreciated!
Upgrading Python to 2.7.1, running "Update Shell Profile" command file which is located in Python directory and changing the Python settings in Netbeans according to new installation worked for me.
Yeah, you'll need to regenerate all your *.pyc and *.pyo files from the *.py files.
How you do this depends on how they were generated in the first place. Some packaging of python (and it's add-ons), such as in some Linux distros, gets a little too clever for its own good and keeps the original *.py files somewhere else and have their own build system for generating and placing the *.pyc and/or *.pyo files. In a case like that, you have to use that build system to regenerate them from the original *.py files.
FYI, here are a couple links on *.pyo files. They are the optimized versions of compiled python modules.
On OS X Lion, you should have a os.py file. This is likely the root cause of your error. The os.pyc file was generated from a different version of python than you are running now. Normally, I imagine the python interpreter would just regenerate the file from os.py. But for whatever reason, your system does not have that file.
I suspect that this is a small data point in a larger set of issues and would, in general, recommend a reinstallation of your operating system.
For comparison, I'm running 10.7.1, and I have the following:
[2:23pm][wlynch#orange workout] ls /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/os.*
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/os.py
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/os.pyc
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/os.pyo
As an aside, the *.pyo file is an optimized version of the python bytecode.