I decided to develop a web application with Python with an acquaintance, so I made a memorandum.
There is a Windows version of the article in a similar article. (Windows version article)
Create in the following environment so that all members can use the PC owned by the member for free because there are multiple environments of Mac and Windows. For the time being, create up to Intellisense debug execution with VSCODE.
・ IDE
VSCode version 1.8.1
·language
Python3
Django 1.10.4
・ OS
Mac OS Sierra
I am working with reference to this article (thanks) Introduction to Python Django (1) -Introduction to Python Django (2) Mac Edition
Python Path and Version pythonVSCode some virtualenv issues #148 Troubleshooting Intellisense Autocompletion
$ xcode-select --install
Install with the above command.
Python 2 series is installed by default, but since it was planned to be developed in 3, install 3
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install with the above command
$ brew update
$ brew info python3
python3: stable 3.6.0 (bottled), HEAD
$ brew install python3
You can check the version with the following command
$ python3 -V
Python 3.6.0
Since virtualenv is a tool to create a Python virtual environment for each development environment, install it.
$ cd
$ mkdir Develop
$ cd Develop
$ mkdir Sandbox
$ cd Sandbox
$ mkdir Python
I think that the location of the directory to be created may be personal preference.
$ cd
$ sudo easy_install pip
$ sudo pip install virtualenv virtualenvwrapper --ignore-installed six
.bashrc
export WORKON_HOME=$HOME/Develop/Sandbox/Python
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python
source /usr/local/bin/virtualenvwrapper.sh
WORKON_HOME is the default folder where the virtual environment is created. VIRTUALENVWRAPPER_PYTHON is the path to Python with Virtualenvwrapper installed.
.bash_profile
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
$ source .bash_profile
$ mkvirtualenv --no-site-package --python /usr/local/bin/python3 env1
--- Select python3 installed with python Set not to use python site-package which is paste with --no-site-package After the above command, the command line will be displayed as (env1) $ because the virtual environment is being used.
(env1) $pip install django==1.10.4
(env1) $pip freeze -l
Django==1.10.4
(env1) $ cd
(env1) $ cd Develop
(env1) $ mkdir PythonSites
(env1) $ cd PythonSites
(env1) $ django-admin.py startproject myTestSite
Please choose the development folder to your liking. In the above, you will have (user directory) / Develop / PythonSites / myTestSite.
Download and install from Visual Studio Code
Install Python by typing Python from View> Extensions (Don Jayamanne's guy)
Enter shell in View> Command Palette and set it so that it can be started with code
$ cd
$ cd Develop/PythonSites/myTestSite
$ workon env1
(env1) $ code .
Note that if you do not use the above login method, the default virtual environment settings and other settings will be incorrect.
setting.js
//Insert settings in this file to override the default and user settings
{
"python.pythonPath": "${env.PYTHONPATH}/env1/bin/python",
"python.linting.pylintEnabled": false,
"python.linting.pep8Enabled": true
}
It is mainly set to make intellisense effective. The location of the file is Code> Basic Settings> Workspace Settings. Set only when you open this workspace.
For the time being, in order to create a template file, click the debug icon from the menu on the left and forcibly execute debugging.
lounch.json
{
"name": "Django",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "/Users/userName/Develop/Sandbox/Python/env1/bin/python3",
"program": "${workspaceRoot}/manage.py",
"cwd": "${workspaceRoot}",
"args": [
"runserver",
"--noreload"
],
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput",
"DjangoDebugging"
]
},
If you touch only the PythonPath item, it's OK, please go through the path to the virtual environment.
If you do so far, intellisense Debug execution Should work (tabun)