国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

在Dreamhost上使用virtualenv更新新的Django和Python 2.7。*(帶乘客)

瀏覽:95日期:2022-08-07 13:08:46
如何解決在Dreamhost上使用virtualenv更新新的Django和Python 2.7。*(帶乘客)?

我目前有私人服務(wù)器,一個(gè)外殼帳戶和一點(diǎn)運(yùn)氣。所以這是我的工作:

SSH到您的主機(jī)以升級(jí)python

cd ~

mkdir tmp cd tmp wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz tar zxvf Python-2.7.3.tgz cd Python-2.7.3 ./configure –enable-shared –prefix=$HOME/Python27 –enable-unicode=ucs4 make make install

配置系統(tǒng)以使用我們的新Python。打開?/ .bashrc并添加以下行

export PATH='$HOME/Python27/bin:$PATH'

export LD_LIBRARY_PATH=$HOME/Python27/lib

#save it and run source ~/.bashrc

您現(xiàn)在可以使用檢查您的python版本 which python

安裝easy_install,pip

cd ~/tmp

wget http://peak.telecommunity.com/dist/ez_setup.pypython ez_setup.pyeasy_install pip

Or even shorter

wget https://bootstrap.pypa.io/get-pip.pypython get-pip.py

安裝 virtualenv

pip install virtualenv

virtualenv $HOME//env #Switch to virtualenv source $HOME//env/bin/activate

您還可以將env路徑添加到 bashrc

export PATH='$HOME/<site>/env/bin/:$PATH' source ~/.bashrc

安裝Django和其他所有東西

pip install django

pip install .... pip install .... pip install ....

建立專案

cd $HOME/<site>/

python $HOME//env/bin/django-admin.py startproject project

創(chuàng)建passenger_wsgi.py于HOME/<site>/與下列內(nèi)容

import sys, os

cwd = os.getcwd() sys.path.append(cwd) sys.path.append(cwd + ‘/project’) #You must add your project here or 500

#Switch to new python #You may try to replace $HOME with your actual path if sys.version < “2.7.3”: os.execl(“$HOME//env/bin/python”, “python2.7.3”, *sys.argv)

sys.path.insert(0,’$HOME//env/bin’) sys.path.insert(0,’$HOME//env/lib/python2.7/site-packages/django’) sys.path.insert(0,’$HOME//env/lib/python2.7/site-packages’)

os.environ[‘DJANGO_SETTINGS_MODULE’] = “project.settings” import django.core.handlers.wsgi application = django.core.handlers.wsgi.WsgiHandler()

或者這樣

import sys, osBASE_DIR = os.path.dirname(os.path.abspath(__file__))sys.path.append(os.path.join(BASE_DIR)) #You must add your project here or 500#Switch to new python#You may try to replace $HOME with your actual pathPYTHON_PATH = os.path.join(BASE_DIR, ’env’, ’bin’, ’python’)if sys.executable != PYTHON_PATH: os.execl(PYTHON_PATH, 'python2.7.12', *sys.argv)

如果您使用的是django 1.7,請(qǐng)將最后兩行替換為

from django.core.wsgi import get_wsgi_applicationapplication = get_wsgi_application()享受:D

Dreamhost上的新版本python將不再返回,sys.executable因此您這是我的passenger_wsgi版本

import sys, osVIRTUAL_ENV_PYTHON = ’venv-python’ # Python > 2.7.6 dreamhost not return sys.executableBASE_DIR = os.path.dirname(os.path.abspath(__file__))def is_venv_python(): if len(sys.argv) > 0:last_item = sys.argv[len(sys.argv)-1]if last_item == VIRTUAL_ENV_PYTHON: return True return Falsesys.path.append(os.path.join(BASE_DIR)) #You must add your project here or 500#Switch to new pythonPYTHON_PATH = os.path.join(BASE_DIR, ’env’, ’bin’, ’python’)if not is_venv_python(): os.execl(PYTHON_PATH, 'python2.7.12', *sys.argv + [VIRTUAL_ENV_PYTHON])sys.path.insert(0, os.path.join(BASE_DIR, ’env’, ’bin’))sys.path.insert(0, os.path.join( BASE_DIR, ’env’, ’lib’, ’python2.7’, ’site-packages’))解決方法

Dreamhost是小型項(xiàng)目的理想主機(jī)。而且它也是Django友好的托管。除python和Django版本外,其他所有功能都過時(shí)了。好吧,這是一整天的工作,要弄清楚如何在dreamhost上更新Python2.7.3,Django 1.4,我真的想與任何發(fā)現(xiàn)它的人分享

標(biāo)簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 保德县| 定兴县| 宝丰县| 武穴市| 浦县| 禹州市| 莆田市| 宣威市| 彭泽县| 桃园市| 禹州市| 凤阳县| 马关县| 淮南市| 晋中市| 鄯善县| 瓮安县| 贵定县| 平乡县| 宿松县| 宜章县| 宜州市| 林周县| 饶平县| 卢氏县| 阿拉善左旗| 平原县| 崇阳县| 满洲里市| 溧水县| 昌邑市| 太仆寺旗| 囊谦县| 洛宁县| 山西省| 蓬莱市| 盐边县| 江达县| 偏关县| 崇仁县| 双江|