0

my project directory looks like this

-- PycharmProjects   #foldrname
     - imp_func      #foldrname
            - funcs.py  #having a class name "specs"  
     - project1      #foldrname
            - projct.py  

I want to import class "specs" which is in funcs.py into projct.py

Code tried:

 from PycharmProjects.imp_func.funcs import specs   # UnResolved reference PycharmProjects
Amit
  • 763
  • 1
  • 5
  • 14

1 Answers1

0

Oops... Python packages are indeed represented as subdirectories, but not all directories are packages! The from x import y only makes sense if x is a python module or a Python package and if it is accessible from the Python path.

Here the correct way would be to put the imp_func folder in the Python path, for example by putting it into the PYTHONPATH environment variable. Then you will be able to use:

from funcs import specs
Serge Ballesta
  • 143,923
  • 11
  • 122
  • 252