Python Forum
Import a module one step back of the path
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Import a module one step back of the path
#2
Look at this post for advice.
So test folder and tests should advisable be outside of the package folder.
Then import stuff from package folder and test it outside of the package.
(Sep-21-2022, 09:31 AM)prathampatel9 Wrote: Kindly help me how can we import this without using sys path
Maybe you misunderstand how sys.path work,Python can not find anything whiteout it.
When make package so should project folder be in sys.path the will Python find package(all files and sub-folder) and test folder.
So Python only need to find the project folder,in example in post i make virtual environment(sys.path set as default to folder to project folder).
One more example A sample Python project.
Reply


Messages In This Thread
RE: Import a module one step back of the path - by snippsat - Sep-21-2022, 01:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  import a function from another file using relative path paul18fr 6 3,170 Aug-01-2024, 06:40 AM
Last Post: paul18fr
  is import cointegration_analysis a recognized module mitcht33 1 1,147 Nov-06-2023, 09:29 PM
Last Post: deanhystad
  problem in import module from other folder akbarza 5 10,477 Sep-01-2023, 07:48 AM
Last Post: Gribouillis
  can not import anaconda pandas module. PySpark pandas module is imported!! aupres 0 1,382 Aug-06-2023, 01:09 AM
Last Post: aupres
  import module error tantony 5 5,021 Dec-15-2022, 01:55 PM
Last Post: Lauraburmrs
  Import a module for use in type hint? Milosz 0 2,063 Nov-08-2021, 06:49 PM
Last Post: Milosz
  Can't install nor import delorean module Tek 3 4,246 Oct-27-2021, 03:32 AM
Last Post: Tek
  WebDriverException: Message: 'PATH TO CHROME DRIVER' executable needs to be in PATH Led_Zeppelin 1 3,209 Sep-09-2021, 01:25 PM
Last Post: Yoriz
  import module with syntax error Skaperen 7 8,721 Jun-22-2021, 10:38 AM
Last Post: Skaperen
  'import Path' do not understand how to use it tester_V 2 2,566 Jun-19-2021, 02:23 AM
Last Post: tester_V

Forum Jump:

User Panel Messages

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