12

I encountered the Invalid name for Python module: ...filename (it'll not be analyzed) warning message in PyDev and I tried to resolve it by replacing - in the filename with _ but the warning didn't disappeared.

One of the problems is that in fact this is not a module, it's just a python script, still I get the warning and the warning says nothing about how to solve the issue.

What are the real requirements for filenames (not necessary modules) and where are they specified (PIP)?

How do I solve this problem in PyDev?

3
  • 1
    A "python script" is a python module. Sep 26, 2011 at 8:18
  • What is the module name?
    – rob
    Sep 26, 2011 at 8:21
  • The filename. See my answer for what's valid in a module name. Sep 26, 2011 at 8:22

2 Answers 2

16

See http://docs.python.org/tutorial/modules.html for information about modules.

To find out what characters are valid, have a look at the syntax of the import statement. It shows you that a module name needs to be a valid identifier which has the following rule:

identifier ::=  (letter|"_") (letter | digit | "_")*
2
  • 1
    In fact, the problem was the usage of "." in the filename, not the "_", marked as solved.
    – sorin
    Sep 26, 2011 at 8:27
  • 13
    The '-' characters is also not valid in filename. Aug 12, 2013 at 15:17
0

I had the similar message and when I checked the script file name, I had a "-" [dash character] in the script name. After I removed the dash character and replaced with " _ " [an under score character], the warning message was gone.

1

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.