Building a Python development environment on Windows -From installing Anaconda to linking Atom and Jupyter Notebook-

Hello. I'm scared by the first post of Qiita. Please point out any mistakes ...!

About this article

This article is a compilation of previously Posted to note. I'm stuck with building the environment, so I'll leave it as a memorandum.

What you want to achieve

Build a Python development environment

--Installing Anaconda --Installing Atom --Link Atom with Git, GitHub, Jupyter Notebook

About Anaconda

Anaconda is a platform that provides Python packages for data science. We provide compiled binary files of many modules and tools centered on scientific calculations, and you can easily build an environment that uses Python. https://www.python.jp/install/anaconda/index.html

When you install Anaconda, it seems that various useful libraries are included in addition to Python itself. Thank you for beginners.

About Jupyter Notebook

picture_pc_909390423e1bfe108efd47373863af17.png Jupyter Notebook is a tool that can be used while recording the execution result of the program like this. It can be executed cell by cell, you can draw a graph, and you can write a description with markdown. Works with a web browser.

About Atom

Atom is an open source text editor on GitHub. It can be used on both Windows and Mac. picture_pc_8cc85aaf93bac1e52a55622e54ce253f.png And if you install a package called Hydrogen on this Atom, Jupyter Notebook will run on Atom as shown in ↑! This time we will aim for this state.

environment

Windows10

procedure

  1. Install Python (Anaconda)
  2. Create a virtual environment
  3. Install Git
  4. Check Jupyter Notebook
  5. Install Atom
  6. Install Atom package
  7. Hydrogen installation
  8. Cooperation between Atom and Git, GitHub

Let's proceed in order.

1. Install Python (Anaconda)

Install Anaconda from Anaconda Official Website. Select ** 3 ** (3.7 at the time of article creation) for the version. After that, proceed with the installation work according to the instructions of the installer.

2. Create a virtual environment

Next, create a virtual environment.

When developing or experimenting with Python, it is common to create a dedicated execution environment according to the purpose and switch between them. Such an execution environment that is created temporarily is called a "virtual environment". https://www.python.jp/install/windows/venv.html

This time, in order to match the version with the reference book, we built a virtual environment of version 3.6. Launch ** Anaconda Prompt ** (in the start menu) and check the version.

>python

It was Python 3.7.4. When you hit the python command, it will be in interactive mode, so you can exit that state with the following command.

>exit()

Create a version 3.6 virtual environment with the following command:

conda create -n py36 python=3.6 anaconda

If you do this, a new ** Anaconda Prompt (py36) ** (* Hereafter, Anaconda Prompt (x)) will be created (I think it is around the start menu), so start it in the same way. Let's check the version.

>python

Here you can see Python 3.6.10. After that, you can enter this virtual environment by launching this Anaconda Prompt (x).

Also, try switching the version of the library (* this time scikit-learn) (according to the reference book).

Check the library list in the virtual environment

>conda list

Check the version of scikit-learn

>conda list scikit-learn

→ Since it was 0.22.1, switch to 0.19.1.

>conda install scikit-learn==0.19.1

Check the version again

>conda list scikit-learn

→ I was able to confirm it as 0.19.1!

3. Install Git

Install from Git official website.

After installation, I think that an application called ** GitBash ** has been created in the start menu again. Let's launch this.

Set the user name and email address (any one).

$git config --global user.name “user name”
$git config --global user.email “email address"

Create a suitable repository on ** GitHub ** (create an account if you don't have one), and copy and test the address of the remote repository with ** "Clone with HTTPS" **.

$git clone remote repository address

Create a suitable file.

$touch test

push

$git add test
$git commit -m "test"
$git push origin master

Check GitHub, and if the created file is reflected, it is successful. You did it!

4. Check Jupyter Notebook

: snake: * If you get tired, take a break *: snake:

Now, the Jupyter Notebook comes with Anaconda, so no installation is required **.

To use Jupyter normally without linking with Atom, launch ** Anaconda Prompt (x) ** and execute the following command.

>jupyter notebook

I think that the web browser is launched and the Jupyter Notebook screen is displayed.

5. Install Atom

Here, install Atom. Let's install from Atom official website.

6. Install Atom package

After the installation of Atom is completed, the next step is to install the necessary packages (= convenient functions) for Atom. In Atom ** File-> Settings-> Install **, enter the required package name in the search box to search and install.

For the time being, here is the minimum recommendation.

-** japanese-menu : Menu can be translated into Japanese - platformio-ide-terminal : terminal can be used on Atom - Hydrogen **: Cooperation with Jupyter Notebook

7. Hydrogen installation

** Yes, this guy made me cry. ** ** When I tried to install Hydrogen, the following message was displayed and the installation failed.

Uncaught SyntaxError: Invalid or unexpected token
C:\Users\**\atom\app-1.43.0\resources\app\static\<embedded>:11
Show Stack Trace
The error was thrown from the Hydrogen package. 
This issue has already been reported.

When I jumped to Message link and checked, it seems that the old 2.8.0 is not the latest version (2.13.1 at the moment). I was asked to install it, so ** regain my mind and ** install Hydrogen 2.8.0 at the command prompt.

>apm install [email protected]

Check the installed packages

>apm list --installed —bare
[email protected]
[email protected]
[email protected]

Hydrogen 2.8.0 has been installed!

Next, hit the following command with ** Anaconda Prompt (x) **,

>jupyter kernelspec list —json

I think it will be displayed as below, so copy this ** {** ・ ・ ・ **} ** entirely.

{
 "kernelspecs": {
   "python3": {
     "resource_dir": “********",
     "spec": {
       "argv": [
         “********",
         "-m",
         "ipykernel_launcher",
         "-f",
         "{connection_file}"
       ],
       "env": {},
       "display_name": "Python 3",
       "language": "python",
       "interrupt_mode": "signal",
       "metadata": {}
     }
   }
 }
}

Then paste it into Atom's ** Preferences-> Packages-> Hydrogen-> Settings-> Startup Code **.

In addition, open ** Hydrogen / package.json ** with ** Preferences → Packages → Hydrogen → Settings → View Code **.

At the ** Command Prompt **, type the following command.

>npm info @nteract/presentational-components
@nteract/[email protected] …
.
.
.

Go back to Atom. Add the version shown above to the bottom of the ** dependencies ** item in ** package.json **.

"@nteract/presentational-components”:”^3.3.4"

It is like this.

After saving your changes, return to the ** Command Prompt ** and type the following command.

>apm install
Installing modules done

If it is displayed like ↑, it's OK (probably ...)

Well, this should work! In Atom, run Ctrl + Alt + Enter!

** But nothing happened! ** **

→ ... Close the currently open Atom and launch Atom from ** Anaconda Prompt (x) **.

>atom .

Try running Ctrl + Alt + Enter again. picture_pc_c8216b19d1a5fe35c61669336858f04d.png ** → It was executed successfully! ** **

Apparently Hydrogen doesn't work unless I run Atom from Anaconda Prompt ...

8. Cooperation between Atom and Git, GitHub

Finally, we will link Atom with Git and GitHub.

First, in Atom, select ** Package → GitHub → Toggle Git Tab, Toggle GitHub Tab ** to display the Git and GitHub tabs (appears on the right side of the screen).

On the GitHub tab, you will be prompted to enter the token, so go to the linked GitHub. Upon authentication, a ** token ** will be issued. Copy the token, paste it into the box on Atom's GitHub tab, log in, and you can now integrate Git and GitHub on Atom!

About Hydrogen

# In[]:
Processing ①

# In[]:
Processing ②

You can separate cells with # In []: ~ # In []:. Move the cursor to the area of process ① and press Ctrl + Alt + Enter to execute the process in the cell. You can also select the code you want to execute and press Ctrl + Enter to execute it without dividing the cells as described above.

You can also write it in markdown, so please refer to Hydrogen official document for detailed specifications.

You can also export in Jupyter Notebook (**. Ipynb **) format by running Hydrogen: Export Notebook ** at the prompt with Ctrl + Shift + P`!

It will be like this! picture_pc_cf1ddc3f0fd82a37d4a63842ee6fba55.png Unfortunately, it seems that the specification does not output the execution result ... Still, I feel that it is quite easy to use ...!

Finally

Hydrogen seems to be very convenient, so I want to use it! I came up with the idea, but it was quite difficult. Building an environment is difficult ... I will also write an article about Atom and Python. Thank you for reading this far!

Reference link

GitHub starting today ~ Explaining how beginners can install Git and pull request I installed Git for Windows and tried connecting to GitHub. Use https git How to set Hydrogen for Anaconda (Python3) + Atom About Jupyternotebook-ModuleNotFound I tried using Git / GitHub newly combined with the Atom editor

Recommended Posts

Building a Python development environment on Windows -From installing Anaconda to linking Atom and Jupyter Notebook-
Everything from building a Python environment to running it on Windows
Create a comfortable Python 3 (Anaconda) development environment on windows
Building a Jupyter Lab development environment on WSL2 using Anaconda3
Building a Python environment on a Mac and using Jupyter lab
From installing Ansible to building a Python environment in Vagrant's virtual environment
How to build a Python virtual execution environment using Visual Studio Code and pipenv on a Windows machine (also Jupyter notebook)
Create a Python virtual development environment on Windows
Notes from installing Homebrew to building an Anaconda environment for Python with pyenv
Build a PYNQ environment on Ultra96 V2 and log in to Jupyter Notebook
Build a GVim-based Python development environment on Windows 10 (3) GVim8.0 & Python3.6
Build a GVim-based Python development environment on Windows 10 (1) Installation
[Windows] [Python3] Install python3 and Jupyter Notebook (formerly ipython notebook) on Windows
Procedure for building a CDK environment on Windows (Python)
Create a decent shell and python environment on Windows
How to build a beautiful Python environment on a new Mac and install Jupter Notebook
Summary from building Python 3.4. * From source to building a scientific computing environment
Build a GVim-based Python development environment on Windows 10 (2) Basic settings
Until building a Python development environment using pyenv on Ubuntu 20.04
Building a Python environment on Mac
Python 3.6 on Windows ... and to Xamarin.
Anaconda python environment construction on Windows 10
Building a Python environment on Ubuntu
Install Python development environment on Windows 10
Example of building python development environment on windows (wsl2, vscode, pipenv)
Build a 64-bit Python 2.7 environment with TDM-GCC and MinGW-w64 on Windows 7
Build a Python environment on your Mac with Anaconda and PyCharm
From building a Python environment for inexperienced people to Hello world
Install Anaconda on Mac and upload Jupyter (IPython) notebook to Anaconda Cloud
How to quickly create a machine learning environment using Jupyter Notebook on macOS Sierra with anaconda
Building a Python 3.6 environment with Windows + PowerShell
Creating a python virtual environment on Windows
Linking python and JavaScript with jupyter notebook
Building a Python development environment for AI development
Building a virtual environment for Mayavi dedicated to Python 3.6, Anaconda, Spyder users
Create a Python development environment on Windows (Visual Studio Code remote WSL).
Steps to create a Python virtual environment with VS Code on Windows
Migration from Python2 to Python3 (Python2 is rebuilt as a virtual environment and coexists)
Try to build python and anaconda environment on Mac (by pyenv, conda)
Build a "Deep learning from scratch" learning environment on Cloud9 (jupyter miniconda python3)
Build Linux on a Windows environment. Steps to install Laradock and migrate
Building a python environment with virtualenv and direnv
Simply build a Python 3 execution environment on Windows
Notes on installing Python3 and using pip on Windows7
Building a Python environment with WLS2 + Anaconda + PyCharm
Install OpenCV 4.0 and Python 3.7 on Windows 10 with Anaconda
Build a Python development environment on your Mac
[Python] Web development preparation (building a virtual environment)
[Node-RED] Execute Python on Anaconda virtual environment from Node-RED [Anaconda] [Python]
Set up a Python development environment on Marvericks
[Python] How to install OpenCV on Anaconda [Windows]
[Note] Installing Python 3.6 + α on Windows and RHEL
Building a Python environment on a Sakura VPS server
From Python environment construction to virtual environment construction with anaconda
Build a Python development environment on Raspberry Pi
To avoid seeing hell when installing django-toolbelt on windows, heroku and python3.4 (64bit) ...
How to run a Django application on a Docker container (development and production environment)
Install and set Jupyter Notebook to create a study note creation environment [Mac]
Prepare a development environment that is portable and easy to duplicate without polluting the environment with Python embeddable (Windows)
From setting up Raspberry Pi to installing Python environment
Building a Python environment for pyenv, pyenv-virtualenv, Anaconda (Miniconda)