Question

Je cours à un dépôt Django cloné

python manage.py runserver

Je reçois

Traceback (most recent call last):
  File "manage.py", line 2, in <module>
    from django.core.management import execute_manager
ImportError: No module named django.core.management

Le problème est dans mon PYTHONPATH selon le CEI MacPorts.

Je lance

ls -l $(which python)

Je reçois

lrwxr-xr-x  1 root  wheel    68B Jan 29 12:27 /usr/local/bin/python -> ../../../Library/Frameworks/Python.framework/Versions/2.6/bin/python

Cette commande indique que selon krunk mes CHEMINs sont incorrects: / opt / local / ... devrait être avant / usr / local / ...

Cependant, je ne suis pas sûr de ce qu'il signifie.

Mon PYTHONPATH dans ~ / .zshrc est

export PYTHONPATH=/opt/local/Library/Frameworks/Python.framework/Versions/2.6/:$HOME/.python_libraries:

où / opt / local / ... est le premier chemin comme le suggère krunk.

Je lance

which $PYTHONPATH
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/:/Users/Sam/.python_libraries: not found

Mon PYTHONPATH a quelque chose de mal. Apparemment / opt / locall / ... est pas juste

Comment pouvez-vous obtenir le PYTHONPATH correct?

Était-ce utile?

La solution

Votre problème n'est pas PYTHONPATH, il est avec lui-même PATH - echo $PATH voir, export PATH=whatever de le changer (vous pouvez le faire dans votre ~ / .bashrc par exemple)

.

Vous verrez que dans votre PATH / usr / local / bin en cours avant VIENT / opt / local / bin - vous avez besoin de les échanger si vous voulez python être exécuté à partir de votre MacPorts. Sinon, bien sûr, vous pouvez choisir d'exécuter explicitement / opt / local / bin / python ...

Autres conseils

Je recommande de ne pas utiliser macports et installer Python en utilisant les instructions de Jesse Nöller http://jessenoller.com/2009/03/16/so-you-want-to-use-python-on-the-mac/

Ses instructions supposent Bash, mais doivent travailler la même chose pour zsh.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top