Menu
  • HOME
  • TAGS

sys.path doesn't include PYTHONPATH (must type full path to run django-admin startproject)

python,django,django-admin,pythonpath,sys.path

Since you do have a command line solution that works why not create a batch file in C:\Python34\Scripts possibly called dj-admin.bat which includes either your full command with parameters, if this is the command that you do all of the time, or allows you to use parameters. By the way,...

Get parent of parent directory from python script

python,sys,sys.path

Yes, using os.path.dirname: In [2]: import os In [3]: os.path.dirname('/home/kristina/desire-directory/scripts') Out[3]: '/home/kristina/desire-directory' Pass os.path.abspath(__file__) there if you don't want to hardcode the directory name: import os print(os.path.dirname(os.path.abspath(__file__))) # /home/kristina/desire-directory Another option is the pathlib module (Python 3.4+): from pathlib import Path print(Path(__file__).parent) # /home/kristina/desire-directory Note that Path.parent is Path instance,...

How to make macports python use its own packages over another installation's?

python,python-2.7,macports,sys.path

There are at least two separate root causes for the problem you are seeing. One is that non-system OS X framework builds of Python 2.7, including MacPorts Python 2.7, deliberately include the system Python site-packages location, /Library/Python/2.7/site-packages, in sys.path, normally at the end of sys.path after that instance's own site-packages...