pythonpath

Do I need PYTHONPATH

≡放荡痞女 提交于 2021-02-19 08:20:15
问题 There are many of similar questions about PYTHONPATH and imports but I didn't find exactly what I needed. I have a git repository that contains a few python helper scripts. The scripts are naturally organized in a few packages. Something like: scripts/main.py scripts/other_main.py scripts/__init__.py a/foo.py a/bar.py a/__init__py b/foo.py b/bar.py b/__init__.py __init__.py scripts depends on a and b . I'm using absolute import in all modules. I run python3 scripts/main.py . Everything works

How to set python IDLE to use pythonpath variable in Ubuntu 10.04

谁说我不能喝 提交于 2021-02-08 05:47:44
问题 I have set a pythonpath variable in my ~/.bashrc and it works fine when using python interpreter from the command line and bpython, but IDLE is not recognizing it. How can I configure it to load the pythonpath variable? Thanks in advance 回答1: You can upgrade Ubuntu, because it works fine on my 10.10 machine with the idle-python2.7 package and PYTHONPATH set in my ~/.profile (which shouldn't matter because bash normally loads both) Or you can change sys.path in /usr/bin/idle* as per Setting

Import error despite __init__.py exists in the folder that contains the target module

天大地大妈咪最大 提交于 2021-01-29 18:05:28
问题 I have the following directory structure inside a virtualenv : /dir_a/dir_b/__init__.py /dir_a/dir_b/module_1.py /dir_a/dir_b/module_2.py /dir_a/dir_c/__init__.py /dir_a/dir_c/module_3.py /dir_a/__init__.py /dir_a/module_4.py Inside module_4.py , I can successfully import module_1.py , module_2.py and module_3.py . On the other hand, I cannot import module_4.py within module_3.py (e.g. import dir_a.module_4 ). It complains: "No module named dir_a.module_4" What am I missing here? Do I need to

Path in the PYTHONPATH not in django path

六眼飞鱼酱① 提交于 2021-01-28 20:48:54
问题 I am writing a web based app based on python and django. I have a source code folder containing LIBS directory that has a file named utils.py . When I want to install my app a new line is added to ~/.profile file like export PYTHONPATH=$PYTHONPATH:/home/test/src/LIBS (The path is added based on the installation path) When I run the below code in the interpreter the path is OK: import sys sys.path ['', '/usr/lib/python2.7', '/home/test/src/LIBS', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '

Controlling PYTHONPATH ordering in PyCharm to make the Source Folders are searched first

喜夏-厌秋 提交于 2021-01-28 01:47:20
问题 I create a projectname package, and use PyCharm to debug the code in it. I also use venv for setting up Python environment for the package. I follow the standard package structure as follows. . ├── NAME │ ├── __init__.py │ ├── arith.py │ └── arith.py ├── bin │ └── app.py ├── build │ ├── bdist.macosx-10.11-intel │ └── lib │ └── NAME │ ├── __init__.py │ └── arith.py ├── dist │ └── projectname-0.1-py2.7.egg ├── docs ├── requirements.txt ├── setup.py └── tests ├── __init__.py └── arith_tests.py