ubuntu配置django環境

2021-10-03 18:41:01 字數 3445 閱讀 5242

1、申請雲主機,部署ubuntu主機,開放22埠

2、系統ubuntu16.04,系統自帶2個版本的python,乙個是python2.7,乙個是python3.5

安裝pip工具

sudo apt-get install python3-pip

安裝本地虛擬環境管理工具

sudo apt-get install python3-virtualenv

python2 --version #檢視python2安裝版本

python3 --version #檢視python3安裝版本

echo alias python=python3 >> ~/.bashrc

source ~/.bashrc

python --version  變成python3了

ubuntu檢視 python安裝路徑

s@s-pc:~/mypython$ which python

/usr/bin/python

pip install virtualenv

root@ecs-a20c:/tmp/my_project_output# cd venv

root@ecs-a20c:/tmp/my_project_output/venv# source ./bin/activate

python3 manage.py runserver

#virtualenv 虛擬環境名稱

#virtualenv --python=/usr/bin/python3.6 虛擬環境名稱

pip list

#source activate

#deactivate

virtualenv --python=/usr/bin/python3.6 虛擬環境名稱

virtualenv -p /usr/bin/python3 venv

apt install python-pip

pip install --upgrade pip

pip3 install django

pip install -i django

[root@ecs-1e4c .pip]# virtualenv

-bash: virtualenv: command not found

[root@ecs-1e4c .pip]# pip install virtualenv

looking in indexes:

collecting virtualenv

downloading (4.6 mb)

|████████████████████████████████| 4.6 mb 5.9 mb/s

collecting distlib<1,>=0.3.0

downloading kb)

|████████████████████████████████| 571 kb 104.9 mb/s

collecting importlib-metadata<2,>=0.12; python_version < "3.8"

downloading (30 kb)

downloading (12 kb)

collecting filelock<4,>=3.0.0

downloading (7.6 kb)

collecting six<2,>=1.9.0

downloading (10 kb)

collecting zipp>=0.5

downloading (4.9 kb)

running setup.py install for distlib ... done

[root@ecs-1e4c .pip]# virtualenv

-bash: virtualenv: command not found

[root@ecs-1e4c .pip]# vim /etc/profile

[root@ecs-1e4c ~]# virtualenv --version

-bash: virtualenv: command not found

[root@ecs-1e4c ~]# pip install --upgrade pip

looking in indexes:

requirement already up-to-date: pip in /usr/local/python3/lib/python3.7/site-pac

[root@ecs-1e4c ~]# source /etc/profile

[root@ecs-1e4c bin]# source /etc/profile

[root@ecs-1e4c bin]# virtualenv

[root@ecs-1e4c tmp]# cd my_project_output/

[root@ecs-1e4c my_project_output]# virtualenv --python=python3 venv

created virtual environment cpython3.7.4.final.0-64 in 272ms

creator cpython3posix(dest=/tmp/my_project_output/venv, clear=false, global=false)

activators bashactivator,cshellactivator,fishactivator,powershellactivator,pythonactivator,xonshactivator

[root@ecs-1e4c my_project_output]# cd venv

[root@ecs-1e4c venv]# ls

bin  include  lib  lib  pyvenv.cfg  scripts

[root@ecs-1e4c venv]# source ./bin/activate

(venv) [root@ecs-1e4c venv]#pip install django==2.1.8

cd ..

[root@ecs-1e4c ~]# cd /tmp/my_project_output/

[root@ecs-1e4c my_project_output]# ls

db.sqlite3  gongxin_collect  manage.py  output  static  templates  venv

[root@ecs-1e4c my_project_output]# cd venv

[root@ecs-1e4c venv]# source ./bin/activate

(venv) [root@ecs-1e4c venv]# cd ..

(venv) [root@ecs-1e4c my_project_output]# python3 manage.py runserver 0.0.0.0:8000 &

[1] 9508

盛大雲ubuntu主機配置django環境

1.安裝pip,apt get install pip 2.安裝svn,pip install django 3.安裝django,按上面那篇文章安裝django,用 django admin 命令測試時,出現 importerror no module named django.core 錯誤。解...

ubuntu配置meego qemu開發環境

一 新增meego軟體庫 1.在 etc apt sources.list檔案或者新建 etc apt sources.list.d meego sdk.list檔案中新增以下內容 為平台 版本號 例如 ubuntu 10.04 2.新增公鑰 gpg keyserver pgpkeys.mit.ed...

Ubuntu下配置Codeblocks環境

一 安裝過程 1 安裝基本編譯環境 sudo apt get install build essential sudo apt get install gdb 2 安裝codeblock sudo apt get install codeblocks sudo apt get install cod...