pythonpath

Import Error: No module named django

Import Error: No module named django Question: I am using centos linux. I had python 2.6 with django and now i upgraded to python 2.7. Python 2.6 is located in /usr/lib/python2.6. Python 2.7 is located in /usr/local/lib/python2.7. They both have site-packages directory and they both contain django 1.2. If i run python i get the …

Total answers: 9

Where to put a configuration file in Python?

Where to put a configuration file in Python? Question: In development mode, I have the following directory tree : | my_project/ | setup.py | my_project/ | __init__.py | main.py | conf/ | myproject.conf I use ConfigParser to parse the myproject.conf file. In my code, it’s easy to load the file with a good path : …

Total answers: 7

Best practice for reusing python code

Best practice for reusing python code Question: I have write a python library app(which contains several *.py files). And several of my python projects need to reuse the code in the library app. What’s the recommended best practice for reusing python code? Currently I have thought out three options: Copy and paste. This is far …

Total answers: 4

django import error – No module named core.management

django import error – No module named core.management Question: Ok, I see plenty of these errors around. I have tried everything I know to do and have yet to figure this out. I am working on a development server running python 2.5 and Django 1.3. Django 1.3 was installed using python setup.py install after unpacking …

Total answers: 32

Python – add PYTHONPATH during command line module run

Python – add PYTHONPATH during command line module run Question: I want to run: python somescript.py somecommand But, when I run this I need PYTHONPATH to include a certain directory. I can’t just add it to my environment variables because the directory I want to add changes based on what project I’m running. Is there …

Total answers: 6

How to add to the PYTHONPATH in Windows, so it finds my modules/packages?

How to add to the PYTHONPATH in Windows, so it finds my modules/packages? Question: I have a directory which hosts all of my Django apps (C:My_Projects). I want to add this directory to my PYTHONPATH so I can call the apps directly. I tried adding C:My_Projects; to my Windows Path variable from the Windows GUI …

Total answers: 23

Permanently add a directory to PYTHONPATH?

Permanently add a directory to PYTHONPATH? Question: Whenever I use sys.path.append, the new directory will be added. However, once I close python, the list will revert to the previous (default?) values. How do I permanently add a directory to PYTHONPATH? Asked By: John Howard || Source Answers: If you’re using bash (on a Mac or …

Total answers: 24

Add to python path mac os x

Add to python path mac os x Question: I thought import sys sys.path.append(“/home/me/mydir”) is appending a dir to my pythonpath if I print sys.path my dir is in there. Then I open a new command and it is not there anymore. But somehow Python cant import modules I saved in that dir. What Am I …

Total answers: 7

PYTHONPATH vs. sys.path

PYTHONPATH vs. sys.path Question: Another developer and I disagree about whether PYTHONPATH or sys.path should be used to allow Python to find a Python package in a user (e.g., development) directory. We have a Python project with a typical directory structure: Project setup.py package __init__.py lib.py script.py In script.py, we need to do import package.lib. …

Total answers: 6

How do I find out my PYTHONPATH using Python?

How do I find out my PYTHONPATH using Python? Question: How do I find out which directories are listed in my system’s PYTHONPATH variable, from within a Python script (or the interactive shell)? Asked By: Paul D. Waite || Source Answers: sys.path might include items that aren’t specifically in your PYTHONPATH environment variable. To query …

Total answers: 10