This is my local environment construction memo.
Python is pre-installed on mac, Since the version is 2 series, install 3 series from pyenv. https://github.com/pyenv/pyenv
##First install pyenv
$ brew install pyenv
I will add below
eval "$(pyenv init -)"
Load the edited .zprofile and enable the pvenv command.
$ source ~/.zprofile
$ pyenv install 3.7.1
$ pyenv global 3.7.1
Don't include extra packages in your local global environment (package management on a project-by-project basis) Install Django-related packages on top of your virtual environment.
Use the venv
module to create a virtual environment.
##Create project directory
$ mkdir hogeproject
$ cd hogeproject
##venv virtual environment creation
$ python -m venv myhogeenv
##When you check the created directory, it looks like this
$ pwd
/xxxx/xxxx/hogeproject
$ tree -L 3
.
└── myhogeenv
├── bin
│ ├── activate
│ ├── activate.csh
│ ├── activate.fish
│ ├── easy_install
│ ├── easy_install-3.7
│ ├── pip
│ ├── pip3
│ ├── pip3.7
│ ├── python -> /Users/xxxx/.pyenv/versions/3.7.1/bin/python
│ └── python3 -> python
├── include
├── lib
│ └── python3.7
└── pyvenv.cfg
##Start-up
$ source myhogeenv/bin/activate
##Prompt when startup is complete(myhogeenv)Is attached.
(myhogeenv) $
Install Django with the venv virtual environment running.
(Django installed with pip
)
##Requirements described in Django version.Place txt
(myhogeenv) $ echo "Django~=2.2.4" > requirements.txt
##Deployed requirements.txt Directory check
(myhogeenv) $ pwd
/xxxx/xxxx/hogeproject
(myhogeenv) $ tree -L 3
.
├── myhogeenv
│ ├── bin
│ │ ├── activate
│ │ ├── activate.csh
│ │ ├── activate.fish
│ │ ├── easy_install
│ │ ├── easy_install-3.7
│ │ ├── pip
│ │ ├── pip3
│ │ ├── pip3.7
│ │ ├── python -> /Users/xxxx/.pyenv/versions/3.7.1/bin/python
│ │ └── python3 -> python
│ ├── include
│ ├── lib
│ │ └── python3.7
│ └── pyvenv.cfg
└── requirements.txt
##Django installation
(myhogeenv) $ pip install -r requirements.txt
Recommended Posts