Python Forum
problem with importing my program
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem with importing my program
#1
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.
Reply
#2
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  problem program runs in a loop jasserin 0 248 May-18-2024, 03:07 PM
Last Post: jasserin
  Some help with my first python class and importing ....im making a lidar program jttolleson 7 1,486 Jul-28-2023, 08:34 AM
Last Post: jttolleson
  Problem with importing python-telegram library into the project gandonio 1 1,760 Nov-01-2022, 02:19 AM
Last Post: deanhystad
  Problem with importing Python file in Visual Studio Code DXav 7 5,701 Jun-15-2022, 12:54 PM
Last Post: snippsat
  Importing Program Wide JarredAwesome 4 2,342 Sep-07-2020, 04:34 PM
Last Post: JarredAwesome
  Please help: problem installing/importing langdetect module in Jupyter Notebook ledgreve 3 7,604 Dec-30-2019, 08:17 AM
Last Post: LeanbridgeTech
  Problem with importing and using collections module pythomdummy 3 6,057 Nov-14-2019, 08:48 AM
Last Post: Gribouillis
  Problem with importing a CSV file Chopan2211 6 8,005 Nov-06-2019, 09:25 AM
Last Post: DeaD_EyE
  Problem importing resource library ChrisM 8 4,224 Oct-23-2019, 01:40 PM
Last Post: ChrisM
  Problem: Once I cancel the process my program will start working! Hadad 0 1,732 Jul-24-2019, 04:09 PM
Last Post: Hadad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020