Hello. I'm scared by the first post of Qiita. Please point out any mistakes ...!
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.
Build a Python development environment
--Installing Anaconda --Installing Atom --Link Atom with Git, GitHub, Jupyter Notebook
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.
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.
Atom is an open source text editor on GitHub. It can be used on both Windows and Mac. 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.
Windows10
Let's proceed in order.
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.
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!
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!
: 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.
Here, install Atom. Let's install from Atom official website.
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
** 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.
** → It was executed successfully! ** **
Apparently Hydrogen doesn't work unless I run Atom from Anaconda Prompt ...
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!
# 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! Unfortunately, it seems that the specification does not output the execution result ... Still, I feel that it is quite easy to use ...!
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!
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