Django_start

pip

$python -m pip install 패키지_이름

설치할때 꼭 -m을 붙이는것을 주의해야함!

$python -m pip install Django

현재는 version3.2이용중
그러나 하위 호환이 잘 안됨
파이썬이 직접 인지하고 문제 해결했음

venv 모듈을 만들었음

virtual environment 가상환경을 만들어서 환경을 아예 분리함

그래서 venv1 > version2 django
venv2 > version3 django
이렇게 작업하고 있음
$python -m venv 가상환경_이름

윈도우는 git 을 사용해서 리눅스 환경에서 사용가능함

terminal

ls > list
cd Desktop > desktop 으로 이동 (cd = change directory)
후에 또 ls 로 치면 바탕화면의 list 가 뜸
pwd = present working directory 정확한위치가 나옴

가상환경 만들기

kimhyemin@gimhyemin-ui-MacBookPro desktop % python3 -m venv env
이렇게 하면 바탕화면에 "env"라는 문서가 생성

cd env > ls
들어가고 list 보기

가상환경을 활성할꺼야
activate
가상환경을 비활성화할꺼야
deactivate

kimhyemin@gimhyemin-ui-MacBookPro env % source bin/activate

(tip TAP 키를 치면 자동완성가능)

kimhyemin@gimhyemin-ui-MacBookPro desktop % python -m venv env
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No module named venv
kimhyemin@gimhyemin-ui-MacBookPro desktop % python3 -m venv env
kimhyemin@gimhyemin-ui-MacBookPro desktop % cd env
kimhyemin@gimhyemin-ui-MacBookPro env % ls
bin		include		lib		pyvenv.cfg
kimhyemin@gimhyemin-ui-MacBookPro env % source bin/activate
(env) kimhyemin@gimhyemin-ui-MacBookPro env % deactivate 
kimhyemin@gimhyemin-ui-MacBookPro env % 

버전체크

(env) kimhyemin@gimhyemin-ui-MacBookPro env % python3 -m django --version     
3.1.1

처음에 버그가 있긴함
자동완성이 안되서
가상환경 껏다 다시 키면 됨

(env) kimhyemin@gimhyemin-ui-MacBookPro env % deactivate
kimhyemin@gimhyemin-ui-MacBookPro env % source bin/activate
(env) kimhyemin@gimhyemin-ui-MacBookPro env % django-admin startproject Remystagram

가상환경 폴더 안에 Remystagram 생성

manage.py 가 생성된곳 = project.route 라고 불림
manage.py 가 있는곳에서 보통 함

code = vscode 를 열겠어
현경로를 베이스로 해서 vscode 로 열어줘 > code . (공백중요)


Last login: Wed Sep 23 20:44:58 on ttys002
kimhyemin@gimhyemin-ui-MacBookPro ~ % ls
Applications	Documents	Library		Music		Public
Desktop		Downloads	Movies		Pictures
kimhyemin@gimhyemin-ui-MacBookPro ~ % cd desktop
kimhyemin@gimhyemin-ui-MacBookPro desktop % ls  
Spectacle.app
coding
etc
python_practice
무제 폴더
백준
전기기사
스크린샷 2020-09-19 오후 8.21.28.png
kimhyemin@gimhyemin-ui-MacBookPro desktop % pwd
/Users/kimhyemin/desktop
kimhyemin@gimhyemin-ui-MacBookPro desktop % clear







kimhyemin@gimhyemin-ui-MacBookPro desktop % python -m venv env
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No module named venv
kimhyemin@gimhyemin-ui-MacBookPro desktop % python3 -m venv env
kimhyemin@gimhyemin-ui-MacBookPro desktop % cd env
kimhyemin@gimhyemin-ui-MacBookPro env % ls
bin		include		lib		pyvenv.cfg
kimhyemin@gimhyemin-ui-MacBookPro env % source bin/activate
(env) kimhyemin@gimhyemin-ui-MacBookPro env % deactivate 
kimhyemin@gimhyemin-ui-MacBookPro env % source bin/activate
(env) kimhyemin@gimhyemin-ui-MacBookPro env % python3 -m pip install Django
Collecting Django
  Downloading Django-3.1.1-py3-none-any.whl (7.8 MB)
     |████████████████████████████████| 7.8 MB 1.7 MB/s 
Collecting sqlparse>=0.2.2
  Downloading sqlparse-0.3.1-py2.py3-none-any.whl (40 kB)
     |████████████████████████████████| 40 kB 7.0 MB/s 
Collecting asgiref~=3.2.10
  Downloading asgiref-3.2.10-py3-none-any.whl (19 kB)
Collecting pytz
  Downloading pytz-2020.1-py2.py3-none-any.whl (510 kB)
     |████████████████████████████████| 510 kB 8.2 MB/s 
Installing collected packages: sqlparse, asgiref, pytz, Django
Successfully installed Django-3.1.1 asgiref-3.2.10 pytz-2020.1 sqlparse-0.3.1
WARNING: You are using pip version 20.1.1; however, version 20.2.3 is available.
You should consider upgrading via the '/Users/kimhyemin/Desktop/env/bin/python3 -m pip install --upgrade pip' command.
(env) kimhyemin@gimhyemin-ui-MacBookPro env % python3 -m pip install --upgrade pip
Collecting pip
  Downloading pip-20.2.3-py2.py3-none-any.whl (1.5 MB)
     |████████████████████████████████| 1.5 MB 839 kB/s 
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.1.1
    Uninstalling pip-20.1.1:
      Successfully uninstalled pip-20.1.1
Successfully installed pip-20.2.3
(env) kimhyemin@gimhyemin-ui-MacBookPro env % python3 -m django --version     
3.1.1
(env) kimhyemin@gimhyemin-ui-MacBookPro env % deactivate
kimhyemin@gimhyemin-ui-MacBookPro env % source bin/activate
(env) kimhyemin@gimhyemin-ui-MacBookPro env % django-admin startproject Remystagram
(env) kimhyemin@gimhyemin-ui-MacBookPro env % cd Remystagram
(env) kimhyemin@gimhyemin-ui-MacBookPro Remystagram % ls
Remystagram	manage.py
(env) kimhyemin@gimhyemin-ui-MacBookPro Remystagram % code .
zsh: command not found: code
(env) kimhyemin@gimhyemin-ui-MacBookPro Remystagram % code .

. 현재위치
..이전위치

그러나

kimhyemin@gimhyemin-ui-MacBookPro Remystagram % source ../bin/activate

요렇게 한번에 가기!

그럼 가상환경에 다시 들어올수 있음

(env) kimhyemin@gimhyemin-ui-MacBookPro Remystagram % 

파이썬 버젼이 많....
error 나있음...!! 다음시간에 확인

좋은 웹페이지 즐겨찾기