The following lines in Eclipse + PyDev with Python 3.4 work, but it is highlighted as Undefined variable from import: dump error:
import json
with open('C:\\test', 'w') as outfile:
json.dump([1, 2, 3], outfile)
Here is a snapshot of the Eclipse editor:
How do I get rid of that error?
EDIT
The output of:
import json
with open('C:\\test', 'w') as outfile:
json.dump([1, 2, 3], outfile)
print(json.__file__)
Is:
C:\Python34\lib\json\__init__.py
Here is the list of attributes that Eclipse shows:
problem in line 313 in file ../lib/json/__init__.py
...
if s.startswith(u'\ufeff'):
...
change this line to
if s.startswith('\ufeff'):
or wait for the new version
I was not able to get Eclipse to work, but I was able to get rid of the error (and of similar error/warnings): select the highlighted word, press ctrl+1 and select the line containing #UndefinedVariable to add a comment at the end of the row that will tell Eclipse to ignore that error on that line.
I use the same technique to ignore other errors with other modules, and it helps keeping the project clean.
See here for more details.
I had the same problem, but I had a file called json.py. Renaming my file to jsonTest.py from Eclipse left behind a json.pyc. Deleting that file did not help. Doing a Project->Clean did not help. Finally, I created a new workspace and things now work as expected. This was with Eclipse Kepler Release 2.
Adding json to the list of Forced Builtins of your Python Interpreter in PyDev Preferences also fix this issue.
Related
I am getting an error message from Pydev in the Eclipse Console window when debugging Python code. The same error message repeats every time the debugger pauses:
ValueError: invalid literal for int() with base 10: "NameError: name 'psort' is not defined"
Traceback (most recent call last):
File "C:\Users\Bill\.p2\pool\plugins\org.python.pydev.core_9.2.0.202110311311\pysrc\_pydevd_bundle\pydevd_process_net_command.py", line 63, in process_net_command
cmd = on_command(py_db, cmd_id, seq, text)
File "C:\Users\Bill\.p2\pool\plugins\org.python.pydev.core_9.2.0.202110311311\pysrc\_pydevd_bundle\pydevd_process_net_command.py", line 367, in _cmd_exec_or_evaluate_expression
trim_if_too_big = int(trim) == 1
ValueError: invalid literal for int() with base 10: "NameError: name 'psort' is not defined"
This is not a bug in my own code, and I don't know how to fix it. I can't tell if is my configuration or a Pydev bug, or what? The debugger still works, but the console window gets filled up with those repeated messages.
I have been tolerating it for some months, thinking I just had to update Pydev, but I finally updated Pydev today(11/2021) and I still get the error messages.
I am using:
Windows 10 64bit
Eclipse IDE for C/C++, Version: 2020-12 (4.18.0), Build id: 20201210-1552
The Pydev version I updated to today:
Pydev version 9.2.0.20211031131
I may have solved this, or at least a very similar looking problem. I think it was caused by some references in the Eclipse 'Expressions' view. I had let many expressions accumulate in the Expressions View. Some referenced deleted variables, out of scope variables, or variables whose definitions had changed - so expressions using them may have been buggy.
I stopped the errors by removing all of the expressions in the 'Expressions' view. I was then able to add expressions again without causing the error.
Sorry to say, I didn't identify the problem expression(s), so I didn't get to find out how they caused the problem.
I copied the templates from here to add scaffolding with Twitter Bootstrap thanks to the twitter-bootstrap:2.3.2 plugin.
generates-all works with no errors and creates everything with the look of Twitter Bootstrap.
But I get the next (false?) error:
- Groovy:unexpected token: < # line 1, column 1.
At the next line of code:
<%=packageName ? "package ${packageName}\n\n" : ''%>import org.springframework.dao.DataIntegrityViolationException
This is the Eclipse structure:
If it is just a mistake of eclipse, how could I tell it to ignore it?
My solution so far is to comment out all the Controller.groovy class. The issue is that if I want to use "grails generate-all domain_class" I should remember remuving the comment previously.
I am compiling a .c file with a specified _D option MY_OPT. In the properties -> c++ build -> settings -> gcc c compiler -> symbols I creqated an entry and put MY_OPT in as the value.
When I compile I get error 127 saying that DMY_OPT cannot be found. I learned that error 127 means it realy came from bash and, after a bit of thought, I realized that since the dash is not there (as in -DMY_OPT) bash indeed would report that there is no input file named DMY_OPT to be found.
I searched google and stackoverflow and found lots of similar questions, but can't formulate one with narrow enough search terms to fine any remotely related answer, so I hope someone here can help.
NOTE: I removed the SYMBOL and instead put a -DMY_OPT in the miscellaneous field. No change (or I am getting the Eclipse Juno bug about not deleting previous errors.)
I discovered the answer to this question was the test of the overall command line built by Eclipse. Mine read
${COMMAND ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} } ${FLAGS}
^ ^
} accidentally moved to here ---------------------->|
I had meant to move ${FLAGS} to the end of the command line but also managed to move the right side } form ${COMMAND}..
NOTE: This was done to get the compile command line to look like the linker command line where one should move ${FLAGS} to the end of the line thus putting the list of ".o's" and the "-o xxx" before the "_l's: and "-L's" as is required by some releases of gcc/g++.
I want to run the Flex SDK 4.5.1 on Eclipse IDE. I have followed this http://www.seanhsmith.com/2010/03/29/flex-for-free-setting-up-the-flex-4-sdk-with-eclipse-ide/
step by step and it was same as it was written.
But then when i first built my sample code and ran it, it gave me these errors. I cant figure out what the problem is:
This is the sample code:
and these are the ERRORS:
Loading configuration file C:\Mario's Files\STF\Flex SDK\flex_sdk_4.5.1.21328\frameworks\flex-config.xml
_application_Styles.as(24): col: 38 Error: Syntax error: expecting rightparen before s.
[Embed(_resolvedSource='C:/Mario's Files/STF/Flex SDK/flex_sdk_4.5.1.21328/frameworks/libs/framework.swc$Assets.swf', symbol='mx.skins.cursor.BusyCursor', source='C:/Mario's Files/STF/Flex SDK/flex_sdk_4.5.1.21328/frameworks/libs/framework.swc$Assets.swf', original='Assets.swf', _line='194', _pathsep='true', _file='C:/Mario's Files/STF/Flex SDK/flex_sdk_4.5.1.21328/frameworks/libs/framework.swc$defaults.css')]
^
Any solutions?
Do we have to get a compatible Eclipse-FlexSDK-Flash version??
The ' in "Mario's Files" throws off the parser, because it assumes the path ends there. Your folder names should not have a ' in it, ever. Call the folder "Marios Files" and you're fine.
Read up on String delimiters and escape characters, it's knowledge you will need anyway at some point.
This question might also be off-topic.
orig post:
Hello List,
I am new to Java, Netbeans, and the IB Java API.
I downloaded the IB Java API software and I am using Netbeans to look at it.
On one of the files, Netbeans is indicating a problem with the file.
At the very top of the file, the author has placed a package declaration:
package samples.rfq;
Netbeans is using a red-dot to the left of the package declaration to tell me that it has a problem with the package declaration.
When I mouse-hover the package declaration, Netbeans tells me this:
Incorrect Package (Alt-Enter shows hints)
On my Mac-keyboard I press Alt-Enter and Netbeans just interprets that as an Enter (and then I need to undo that Enter).
I have 2 questions:
How do I work around the Alt-Enter-bug to see the hints?
What do you typically do when Netbeans indicates 'Incorrect Package' on one of your package declarations?
My comment to Josefx:
josefx,
I think maybe you gave me a good clue.
I looked at the file and I see it here in the (Linux) file system:
a#z2:/pt/z2/api$
a#z2:/pt/z2/api$ ls -la /pt/z2/api/samples/rfq/SampleRfq.java
-rw-r--r-- 1 a a 14475 2008-08-13 15:49 /pt/z2/api/samples/rfq/SampleRfq.java
a#z2:/pt/z2/api$
a#z2:/pt/z2/api$
a#z2:/pt/z2/api$
a#z2:/pt/z2/api$ grep package /pt/z2/api/samples/rfq/SampleRfq.java
package samples.rfq;
a#z2:/pt/z2/api$
So obviously it is in a directory which matches its package declaration.
I tried running javac against the file from a variety of directories.
This works:
cd /pt/z2/api/
javac samples/rfq/SampleRfq.java
If I run javac from any other directory it fails.
So, I see a dependency between 3 things here:
Location of the SampleRfq.java
Syntax in the package declaration
Location of the javac command
Since I got javac to work, I'm convinced of 2 things:
SampleRfq.java is in the correct directory
Syntax in the package declaration is correct
So, it looks like my issue is with Netbeans.
Netbeans is too ... 'stupid' to know that:
SampleRfq.java is in the correct directory
Syntax in the package declaration is correct
How do I help Netbeans?
I posted a question to the Netbeans mail-list and the only answer I got was: "Fix the incorrect file name".
ok,
I got the error to evaporate.
steps:
abandon my netbeans project
rsync my code to a new directory; create new NB project; (NB will not let me use old code)
right-click-project: select properties
Add folder
Pick the parent of the directory corresponding to the package
Netbeans now "knows" that the package declaration matches the directory structure.