Python import package from different project

Viewed 4080

I'm trying to import a package from a different project, but it's not recognising the project that I'm trying to import from. I've looked at various answers to this question (including python: import another project module named same with a local module).

My project structure looks like this:

Project1
 - __init__.py
 - foo_directory
  - foo.py
  - __init__.py


Project2
 - __init__.py
 -bar_directory
  - bar.py
  - __init__.py

In bar.py I'm trying to do:

import sys
sys.path.append('path/to/Project2')

from Project1.foo_directory import foo.py

I can't work out why it's not recognising Project1 when I try to do an import?

3 Answers
Related