Python Forum
problem with importing my program - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: problem with importing my program (/thread-1019.html)



problem with importing my program - meems - Nov-27-2016

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.


RE: problem with importing my program - micseydel - Nov-27-2016

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.