Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

Post Timeline

added 2 characters in body
Source Link
Will Vousden
  • 33.6k
  • 9
  • 89
  • 97

I have the following structure

.
├── module1
│  ├── __init__.py
│  └── start.py
├── module2
│  ├── __init__.py
│  └── settings.py
└── Pipfile

cat module1/start.py

from module2.settings import VAR
if __name__ == '__main__':
 print(VAR)

cat module2/settings.py

VAR = 'foo'

If I try to run my program I getpipenv shell python module1/start.py

pipenv shell
python module1/start.py
Traceback (most recent call last):
 File "module1/start.py", line 1, in <module>
 from module2.settings import VAR
ModuleNotFoundError: No module named 'module2'

orpipenv run python module1/start.py

pipenv run python module1/start.py
Traceback (most recent call last):
 File "module1/start.py", line 1, in <module>
 from module2.settings import VAR
ModuleNotFoundError: No module named 'module2'

Why doesn't pipenv set PYTHONPATH correctly ?

I have the following structure

.
├── module1
│  ├── __init__.py
│  └── start.py
├── module2
│  ├── __init__.py
│  └── settings.py
└── Pipfile

cat module1/start.py

from module2.settings import VAR
if __name__ == '__main__':
 print(VAR)

cat module2/settings.py

VAR = 'foo'

If I try to run my program I getpipenv shell python module1/start.py

Traceback (most recent call last):
 File "module1/start.py", line 1, in <module>
 from module2.settings import VAR
ModuleNotFoundError: No module named 'module2'

orpipenv run python module1/start.py

Traceback (most recent call last):
 File "module1/start.py", line 1, in <module>
 from module2.settings import VAR
ModuleNotFoundError: No module named 'module2'

Why doesn't pipenv set PYTHONPATH correctly ?

I have the following structure

.
├── module1
│  ├── __init__.py
│  └── start.py
├── module2
│  ├── __init__.py
│  └── settings.py
└── Pipfile

cat module1/start.py

from module2.settings import VAR
if __name__ == '__main__':
 print(VAR)

cat module2/settings.py

VAR = 'foo'

If I try to run my program I get

pipenv shell
python module1/start.py
Traceback (most recent call last):
 File "module1/start.py", line 1, in <module>
 from module2.settings import VAR
ModuleNotFoundError: No module named 'module2'

or

pipenv run python module1/start.py
Traceback (most recent call last):
 File "module1/start.py", line 1, in <module>
 from module2.settings import VAR
ModuleNotFoundError: No module named 'module2'

Why doesn't pipenv set PYTHONPATH correctly ?

Source Link
zzart
  • 11.6k
  • 5
  • 56
  • 47

Pipenv not setting PYTHONPATH

I have the following structure

.
├── module1
│  ├── __init__.py
│  └── start.py
├── module2
│  ├── __init__.py
│  └── settings.py
└── Pipfile

cat module1/start.py

from module2.settings import VAR
if __name__ == '__main__':
 print(VAR)

cat module2/settings.py

VAR = 'foo'

If I try to run my program I get pipenv shell python module1/start.py

Traceback (most recent call last):
 File "module1/start.py", line 1, in <module>
 from module2.settings import VAR
ModuleNotFoundError: No module named 'module2'

or pipenv run python module1/start.py

Traceback (most recent call last):
 File "module1/start.py", line 1, in <module>
 from module2.settings import VAR
ModuleNotFoundError: No module named 'module2'

Why doesn't pipenv set PYTHONPATH correctly ?

lang-py

AltStyle によって変換されたページ (->オリジナル) /