python - Unable to import a local project to another local one by absolute path: -


i have 2 projects in the different directories, 1 of them want import one. say, project want import has this:

/path123/my_project/main_folder/file1.py /path123/my_project/main_folder/file2.py /path123/my_project/main_folder/file3.py 

here's did in 2nd project:

import sys sys.path.append('/path123/my_project/main_folder') # it's indeed inserted   import main_folder.file1            # error - not found main_folder import file1       # error - not found import my_project.main_folder.file1 # error - not found 

after appended path second python file want use in first python file directly import module filename without extension. example

import file1 

every location in sys.path looked file file1.py import.

say have main python program in /prog1/main.py , want import file /prog2/lib/want_to_import.py in main.py should like

import sys sys.path.append('/prog2/lib') import want_to_import 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -