When I was using Python to plot some figures, the console showed this.
Sorry I can't post pictures.
https://user-images.githubusercontent.com/87467979/216828410-91d5ce76-5d0c-4763-bbd3-b97ceeec5091.png
I don't know how to solve it as I thought it was related to Python packages instead of my codes.
Related
This question already has an answer here:
Task output encoding in VSCode
(1 answer)
Closed 2 years ago.
I'm having a problem with characters not rendering properly.
Background: I am taking online courses to learn Python. I use VSCode as my IDE along with various python extensions.
Problem: Some of the lessons I solve have characters that are beyond the 128 standard ASCII set.
Sample: For clarity, this is the full script I'm dealing with. The currently lesson has text containing a small e with acute (é) in a painting named Vétheuil in the Fog. Unfortunately that acute-e character is rendered as a placeholder (�) and ends up outputting: V�theuil in the Fog.
Efforts: I have done some searching and thought I found a solution: including an encoding flag at the beginning of the python script like this:
# coding=UTF-8
No joy.
Am I tilting at a windmill / misunderstanding purpose or application?
Money Question: Is there a way to get the character to properly render when I run the script?
If you want Unicode characters to be displayed correctly, you'll need to use a terminal, that supports Unicode or change the terminal settings to work with Unicode, in case the terminal provides that option.
Of course the same way you can make the terminal able to display only extended ascii characters like "é" (as long as you have a terminal that provides this functionality), in case you don't need more characters.
This has been sufficiently addressed.
VSCode Panel displays different things via tabs below the editor region. The OUTPUT tab has the displayed different and therefore becomes a question of my setup; not error as the TERMINAL tab displays characters as expected. So, there is no problem to be solved beyond my misunderstand of what was happening.
As #user2357112supportsMonica also provided "An encoding comment declares what encoding your script itself is written in," not how the output is rendered.
Thank you all for helping me through this.
Just to cap this topic. A PERFECT solution to this is provided here:
https://discuss.codecademy.com/t/general-nerdiness-questions/541682/7?u=coreblaster01537
I'm using vim with ConqueTerm and ipython (--pylab if it matters) on Ubuntu 14.04. When I select multiple lines and send them using F9, everything pastes in the same line, as in this question. I could try remapping as the poster did for that question, but I don't have this issue with matlab on the same machine or with ConqueTerm+ipython on mac. Is there a way to fix this so I can continue using F9? Thanks!
The solution
It was my first experience using vimscript, but I was able to modify the plugin so it can send the selected lines properly.
I changed the send_selected function in the conque.vim(or another mirror)\autoload\conque_term.vim to this: https://gist.github.com/freencis/28e351e3bb267a8522e1dff53436fb8d
The function name is the same, just go there and replace it.
What I did
I will skip the "explaing what was wrong" part, mostly because I didn't fully grasp the original implementation.
So, after searching a bit on the internet about how I could access the file's text from a plugin, I ended up finding a way to get the text from specific lines from the file: using the getline function. Luckly there were already a Conque's function to send the line to the terminal and execute it (used by the 's send_file), so I just used it.
Then It was just a matter of knowing which lines were selected and get those. Which led me to the line function, which returns the line number in a different ways. One of these was by marker, in this case the '<, '> markers from the visual selection. Unfortunately I also don't know how to explain these, but calling line("'<") and line("'>") returned me the selection's start and end lines respectively.
And that was the vimscript programming part, the :help is really a life saver. The traditional programming was just looping through the line numbers, getting the text from those and sending them to the terminal.
Notes
It was my first ever experience with vimscript (I've only been using vim for a month), so I'm sure it might not the proper way to do it, plus I replaced a functionality, so I'm just sharing it as a quick hack. Any feedback is appreciated.
Props to http://learnvimscriptthehardway.stevelosh.com/, it helped me a lot with the language, I never expected it to be that accessible
And sorry for any bad English. peace
To start off: I am not familiar with JSON. I think I understand its purpose and formatting, but I'm not trying to be an expert on the subject (and it would seem as though it isn't a very hard 'subject' to master).
But I've run into a problem. I've been trying to download this option data from google, and I'm forced to download it in JSON format. That's fine and all, and I was just going to run it through a python script anyways, so I don't mind it's format. But, I can't get it to work. After reading into all the errors I've been running into, it would seem as though this data isn't formatted correctly. I'm led to assume that this isn't a JSON file at all, but if it's not, then I don't know what to do with it.
Any help would be appreciated. I can't seem to find any resources on this that doesn't just say that this isn't JSON.
I should also point out that, from my naive familiarity with JSON formatting, it would seem as though the problem is that there are strings without double quotes around them. If this is the only issue, then I would wonder why google wouldn't just fix it, so I'm assuming there is something else at play here.
Admittedly this might not have been the original author's intention but this is actually valid CSON, CoffeeScript's version of JSON. I went ahead and tried cson2json from the cson npm package on the file and it worked out great. Here's the JSON on pastebin.
If you want to do the same yourself in an automated manner you can simply use the cson library, that should cover everything for you.
I'm working on adding an image to a GUI interface using Tkinter. In order to eliminate as many factors as possible, I have stripped out everything but the parts relevant to adding an image, yet it still errors out with "tclError:image "pyimageX" doesn't exist" (where X a number). I have followed directly from a tutorial, and I've checked and double checked the file name, and that the file is directly inside the same folder as the program. I have no other ideas to check, and thus, here I am. Thanks for any help you can provide, I'm really hoping I'm not missing anything obvious.
Here's the snippet that's not working:
from tkinter import *
root =Tk()
versionNumRaw = PhotoImage(file="versionNum.gif")
versionNum = Label(root,image=versionNumRaw)
versionNum.pack()
root.mainloop()
Forgive me, as I know this sort of error has been posted before, with answers that have worked for others, but me, still being not having much experience with programming, cant figure out how to apply the answers others have gotten to my own case.
I have a Python3 GUI, where user selects certain values to be statistically evaluated and/or plotted (hist).
Out of this GUI on users request I want to create a report, prefferebly in DOC or/and ODT or/and PDF formats. The layout of the report is pretty much fixed, what will change is: the names of the selected measures and the corresponding values (there are always three measures to display - user selects which), matplotlib histogram (will change depending on the selected settings), user name, date etc.
In some older thread I found a reference to pod package which looks very close to my needs. But I didn't find any good illustration of the resulting documents. And what is most important, I'm not sure if images are allowed there - I would imagine reserving a place for the image somewhere in the corner of the document and update it when user request the report.
EDIT1: pod does NOT support Python3, also after 2to3 convertion and couple of small fixes. There was an advice to use LaTeX, but I'm not sure I understand how to implement this idea without going to the very low level of coding.
Any suggestions are greatly appreciated since the rest of the project is nearly done and this is the last big unsolved problem.
EDIT2: After some break I return to this problem. Since my GUI is in PyQt4, I finally decided to go with QTextDocument and print document to PDF. There are some unclear moments for me in this approach, like if I should use QTextCursor and programically create the document or create somehow HTML first. Also, I have to figure out how to create the document without displaying editor window. Any references with examples are welcome. So far I found only couple of examples in PyQt4\examples\richtext, but they don't answer all my questions.
I try to look at ReportLab now - it doesn't provide DOC (only PDF), but seems to be flexible. As I learned from FAQ, images are allowed, but I will have to save them from matplotlib in jpeg first (PIL is not available for Python3 yet). I hope I will not end up with extreme low level programming for report creation...
Finally solved the problem. It was not so difficult at the end, and I ended up using QTextDocument and its setHtml method to produce the desired document. Related question with the code is here