Trying to build a C++ file using Sublime's console I get the following:
Traceback (most recent call last):
File "./sublime_plugin.py", line 337, in run_
File "./exec.py", line 130, in run
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0301' in position 78: ordinal not in range(128)
I already read this: Sublime text 2 build tools - nothing happens, but after fixing that one I got another error you see above.
Any hints on making this work (allow me to build and run simple C++ codes directly from ST2) would be appreciated, thanks in advance.
Have you tried this?
Sublime Text 2 encoding error with python3 build
I'm using Sublime 3 and it does build simple files (like "hello world") without any problem (using CTRL+B or CTRL+SHIFT+B). I have Windows 8.1, 64 bits.
Seems to me that you're trying to run a program that contains the ยด (acute accent) character. Either that's a mistake and you intended to write the single quote ' instead, or if that's what you wanted, then the Python interpreter does not recognise as an ASCII char (since it isn't) and thus complains.
Related
How to recreate the bug:
Have VScode installed with python
Have python 2.7 environment (either as main or virtual env.)
write a simple test.py to check:
import sys
print(sys.version)
print(sys.executable)
put a break point on second line and start debug.
Expected outcome:
The first line of code is not highlighted for debugging
Under CALL STACK window the module shows as "Unknown Source"
The break point becomes "Unverified Breakpoint"
Under Debug Console window you get this kind of message:
.vscode\extensions\ms-python.python-0.9.1\pythonFiles\PythonTools\visualstudio_py_debugger.py:1669: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
if module.filename.lower() == path.abspath(bp.filename).lower():
Solution:
The next link has gave me the idea, only after looking for issues with the message on 4.
"vscode fails binding breakpoint in debugging python files with path containing chinese in Windows"
resolving it by moving the program to a non unicode path, e.g. c:\python27_WorkingDirectory
meaning if the program test.py resides in a path including unicode characters, the python2.7 does not handle it well and throws all that issues.
Unicode characters are of languages requiring it e.g. Chinese.
Env: Python 2.7
I write some code that write list terms into text files.
Windows sublime remote connected to ubuntu server to edit files
Behavior:
I use file cmd to see the property of the text file, find something interesting.
I guess it could be "xx.txt UTF-8 Unicode text",
but actually it is "xx.txt: DOS executable (COM)"
By mistake I use with clause and f.close() method at the same time. I cannot understand behavior that happens.
Code:
with open(output, 'w') as f:
for comment in sample_list:
f.write(comment + '\n')
f.close()
I have an xml file generated by boost library (using write_xml). When I try to read it using boost's read_xml function, it gives me an error saying
< unspecified file>(20):expected <
when I open the file through vim, correctly written xml tags are ended at 19th line and it shows an additional ^A character at line 20.
This happens in Mac 10.6 xcode 3.2.2 x64 environment.
what does ^A mean?
how could I get rid of this ^A character.
p = subprocess.Popen([executable_file])
This is only code that I am using to run the python subprocess. However, it has unknown issue that cause my program cannot open the executable file as expected.
executable_file is one file link (PATH) that locate executable program.
Ex. C:\Users\SharkIng\Dev\WhatEverSystem\Builds\Windows\program-123456789-123456789.exe
The python subprocess.Popen should run the program. However, sometime it works and sometime it is not (I did not change any code between this two situation)
OS: Windows 10
Python: 2.7.*
Error: [Error 2] The system cannot find the file specified
BUT: It is working if you manually run subprocess.Popen([executable_file_path_string]) (with same file and path) it work.
WHY this happen?? Is that because some problem with Windows Python? or it is because my setting mess me up?
UPDATE: It is not some reason such as NOT FULL PATH. I can have it working with exact same code. If I ran same code in a python shell, by typing each line of code. It works. But if I put exact same code in a .py file and run it with python file.py, it showing the error
UPDATE 2: Another team member have same error with Windows 7 and Python 2.7.* This code used to work this morning. AGAIN I didn't change anything. That is way I am asking if it is unstable.
There is no problem with subprocess. If you want to run a specified executable, you need to give the full path to that file. The most likely reason you're seeing variable behavior is that sometimes you're in the directory with the .exe, and other times you're not.
I'm using xcode to do some c++ programming and all of a sudden I am receiving a "Stray /377 in program error"
I think is possibly because I recently started using a non apple wireless keyboard and I possibly put in some kind of weird key combination that created a non visible key.
I tried changing the encoding of the .cpp file to utf 8 but then when I reopen the file in xcode it comes out in chinese?
My project is very large so its not feasible to post the code for the project.
I'm using xcode 3.2.6 on osx 10.6.8
I tried opening the project in xcode 3.1.6 and got the same error.
"377" is octal for "255", or an 8-bit "-1".
Do you have one of those anywhere?
I believe XCode has a hex editor: just look for "0xff" somewhere in your recent source changes.
Octal 377 is decimal 255. It has no meaning in UTF-8, means a "latin small letter y with diaeresis" in ISO-8859-1. I think its presence in the file is probably a sign that it does not belong and can be removed without further consequences. If you agree, you can try removing all them in your entire tree like this:
find . -name '*.cpp' -exec sed -i~ 's/\o377//g' {} \;
The -i~ asks sed to make a backup copy of the files that it changes, in case you need the originals back -- or want to compare the changes with diff(1).