Python Forum
How to import another Python in different directory?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to import another Python in different directory?
#4
Added the directory where the Python program is located to the sys.path, then import the Python program.

import sys
file_dir = "c:\\Users\\dee\\Documents\\_Python"
sys.path.append( file_dir )
import Connection as conn
Reply


Messages In This Thread
RE: How to import another Python in different directory? - by dee - Sep-28-2022, 06:41 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python 2.7 Import error. Directory and filename conflict petcoo00 2 2,395 Feb-02-2020, 08:46 PM
Last Post: snippsat
  wordpress-python-xmlrpc. I can import 1 file. How do I import the entire folder? SamLearnsPython 0 3,274 Jul-05-2018, 06:21 AM
Last Post: SamLearnsPython
  How to import a file from outside the directory sylas 5 6,710 May-10-2018, 07:19 AM
Last Post: Larz60+
  How to import dependencies from a different directory? ayunus 3 2,791 Feb-11-2018, 04:22 AM
Last Post: ayunus

Forum Jump:

User Panel Messages

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