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
  Some help with my first python class and importing ....im making a lidar program jttolleson 7 1,199 Jul-28-2023, 08:34 AM
Last Post: jttolleson
  Problem with importing python-telegram library into the project gandonio 1 1,563 Nov-01-2022, 02:19 AM
Last Post: deanhystad
  Problem with importing Python file in Visual Studio Code DXav 7 5,066 Jun-15-2022, 12:54 PM
Last Post: snippsat
  Importing Program Wide JarredAwesome 4 2,181 Sep-07-2020, 04:34 PM
Last Post: JarredAwesome
  Please help: problem installing/importing langdetect module in Jupyter Notebook ledgreve 3 7,267 Dec-30-2019, 08:17 AM
Last Post: LeanbridgeTech
  Problem with importing and using collections module pythomdummy 3 5,795 Nov-14-2019, 08:48 AM
Last Post: Gribouillis
  Problem with importing a CSV file Chopan2211 6 7,687 Nov-06-2019, 09:25 AM
Last Post: DeaD_EyE
  Problem importing resource library ChrisM 8 3,940 Oct-23-2019, 01:40 PM
Last Post: ChrisM
  Problem: Once I cancel the process my program will start working! Hadad 0 1,644 Jul-24-2019, 04:09 PM
Last Post: Hadad
  Problem with importing an installed package Reverend_Jim 4 3,701 Jun-14-2019, 10:20 PM
Last Post: Reverend_Jim

Forum Jump:

User Panel Messages

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