Import Error: No module named django

后端 未结 7 1570
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-30 07:34

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 i

相关标签:
7条回答
  • 2020-11-30 08:22

    Under linux, you can set the PYTHONPATH environment variable in your .profile or .bashrc. You can either edit it directly from the terminal by changing to your home directory (cd ~), and then edit the file (nano .bashrc), or by opening the file with gtkedit or vim or whatever, and add:

    PYTHONPATH=/usr/local/lib/python2.7/site-packages:/another/path/etc
    

    If you want to test this before editing your profile, you can export this from the terminal as:

    export PYTHONPATH=/local/lib/python2.7/site-packages
    

    I'm assuming you're running this straight from the command line. If you're running it as a wsgi module in apache, you can add this to your syspath from your wsgi file as:

    import sys
    sys.path.append('/usr/local/lib/python2.7/site-packages')
    
    0 讨论(0)
提交回复
热议问题