1. 程式人生 > 實用技巧 >有關建立虛擬環境的總結

有關建立虛擬環境的總結

1 建立虛擬環境 virtualenv
- --安裝# pip intall virtualenv
2 --- 進入要建立虛擬環境目錄下:

# cd :d #cd virtualenvs
3 ----建立虛擬環境,建立【環境名稱】資料夾,放置所有環境變數
# virtualenv 專案名稱 --python=Python3.6
--python=Python27.exe
--python='C:\Python\Python36\python.exe
4 ---啟用虛擬環境和退出虛擬環境

# 進入 虛擬環境目錄: cd trace
# 進入 scripts目錄 :cd scripts
# activate
5 出現(專案名稱):的標準就是表示啟用成功
----虛擬環境安裝django
python3.7 和django1.11.7 不相容 .可以安裝 django.1.11.28
6 執行: pip install django==1.11.7
----搭建django環境
提醒:先去建立虛擬環境

7 建立django專案

django-admin startproject applet

8 建立 app

cd applet

python manage.py startappp myapp

注意事項: 在建立APP可能出現

解決辦法:修改指定路徑下的functools.py檔案的def total_ordering(cls):方法:

原來的樣子:

convert = {
        '__lt__': [('__gt__', lambda self, other: other < self),
                   ('__le__', lambda self, other: not other < self),
                   ('__ge__', lambda self, other: not self < other)],
        '__le__': [('__ge__', lambda self, other: other <= self),
                   ('__lt__', lambda self, other: not other <= self),
                   ('__gt__', lambda self, other: not self <= other)],
        '__gt__': [('__lt__', lambda self, other: other > self),
                   ('__ge__', lambda self, other: not other > self),
                   ('__le__', lambda self, other: not self > other)],
        '__ge__': [('__le__', lambda self, other: other >= self),
                   ('__gt__', lambda self, other: not other >= self),
                   ('__lt__', lambda self, other: not self >= other)]
    }

修改後的樣子:

convert = {  
    '__lt__': [('__gt__', lambda self, other: not (self < other or self == other)),  
               ('__le__', lambda self, other: self < other or self == other),  
               ('__ge__', lambda self, other: not self < other)],  
    '__le__': [('__ge__', lambda self, other: not self <= other or self == other),  
               ('__lt__', lambda self, other: self <= other and not self == other),  
               ('__gt__', lambda self, other: not self <= other)],  
    '__gt__': [('__lt__', lambda self, other: not (self > other or self == other)),  
               ('__ge__', lambda self, other: self > other or self == other),  
               ('__le__', lambda self, other: not self > other)],  
    '__ge__': [('__le__', lambda self, other: (not self >= other) or self == other),  
               ('__gt__', lambda self, other: self >= other and not self == other),  
               ('__lt__', lambda self, other: not self >= other)]  
}

改完之後即可建立app