Python Forum

Full Version: problem with importing my program
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Just trying to have a go with python debugger

From the python cmd line

 >>> import pdb 
so far so good...

>>> import C:\users\me\documents\my_python\test.py 
gives a syntax error " invalid syntax " with a  pointer to the :
tried a few variations, but no, python really doesn't like file addresses, just spits them all out with roughly the same syntax error.
You can't import a path, instead you should make sure that your script is somewhere Python knows to find it. It's also a pitfall to name your script the name of an existing module; you can check for this by opening a Python shell and trying to import it before you've created it (e.g. in this case import test, which will work). Your version can "shadow" the built-in version, and if something else relied on it, that thing will be broken.

So: rename your file to something unique, and make sure your path is all good, and things should work as expected.