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
  Different Ways to Import Modules RockBlok 2 537 Dec-11-2023, 04:29 PM
Last Post: deanhystad
  How to see the date of installation of python modules. newbieAuggie2019 4 1,618 Mar-31-2023, 12:40 PM
Last Post: newbieAuggie2019
  Import Modules TheBunyip 4 1,251 Mar-10-2023, 04:47 PM
Last Post: buran
  a bunch of modules to import Skaperen 2 896 Nov-07-2022, 07:33 PM
Last Post: Gribouillis
  Python modules for accessing the configuration of relevant paths Imago 1 1,381 May-07-2022, 07:28 PM
Last Post: Larz60+
  Python modules to extract data from a graph? bigmit37 5 22,432 Apr-09-2021, 02:15 PM
Last Post: TysonL
  Where to add own python modules in WinPython? HinterhaeltigesSchlaengelchen 1 2,289 Jan-21-2021, 07:45 PM
Last Post: snippsat
  Did interpreter 'compile' all import modules(from thrid-party) jamesyuan 10 4,313 Oct-19-2020, 10:49 AM
Last Post: jamesyuan
  Including modules in Python using sys.path.append JoeDainton123 1 2,912 Aug-24-2020, 04:51 AM
Last Post: millpond
  how to get PID's of linux commands executed through python modules? Manikandan_PS 4 3,055 Mar-12-2020, 07:16 AM
Last Post: Manikandan_PS

Forum Jump:

User Panel Messages

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