Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Import Python Modules
#1
I am working to make a pyhton web framework, I make a package and installed that, and the main directory is in
venv/lib/python3.6/site-packages/main-folder ,
In the directort where venv is situated there I made a file and importing a module, that module is situated in the main-folder , but from parent directory i can't import that. I am working in virtual environment. Is there any way that I can easily import that needed stuff even though I am not in same directory as main-folder.
I want to import just like, import time
how to make my module so that it can be easily imported without copying directory to current path.?
Reply
#2
You should be able to do
from main-folder import <file to import>

or if the name of the file is "__init__"
import main-folder
Reply
#3
error: no module named file.py
Reply
#4
is "file.py" the name of your file
and can I see the code

If the file is in a folder and u are using the from method. You may have to add a __init__ file to the folder so it is recognized as a package. The __init__ file can empty
Reply
#5
zowhair Wrote:error: no module named file.py
Please post the whole exception traceback that python writes in your console.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Conversion of Oracle PL/SQL(packages, functions, procedures) to python modules. DivyaKumar 3 9,607 Oct-01-2024, 03:32 PM
Last Post: Alex_Kirpichny
Bug Python 3.12 cannot import local python files as modules sunflowerdog 25 47,291 Jul-31-2024, 01:52 PM
Last Post: sunflowerdog
  Different Ways to Import Modules RockBlok 2 1,870 Dec-11-2023, 04:29 PM
Last Post: deanhystad
  How to see the date of installation of python modules. newbieAuggie2019 4 7,334 Mar-31-2023, 12:40 PM
Last Post: newbieAuggie2019
  Import Modules TheBunyip 4 2,889 Mar-10-2023, 04:47 PM
Last Post: buran
  a bunch of modules to import Skaperen 2 2,058 Nov-07-2022, 07:33 PM
Last Post: Gribouillis
  Python modules for accessing the configuration of relevant paths Imago 1 3,367 May-07-2022, 07:28 PM
Last Post: Larz60+
  Python modules to extract data from a graph? bigmit37 5 32,922 Apr-09-2021, 02:15 PM
Last Post: TysonL
  Where to add own python modules in WinPython? HinterhaeltigesSchlaengelchen 1 3,754 Jan-21-2021, 07:45 PM
Last Post: snippsat
  Did interpreter 'compile' all import modules(from thrid-party) jamesyuan 10 8,826 Oct-19-2020, 10:49 AM
Last Post: jamesyuan

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.