How to install and run Python in Atom under Win10 environment
This article will introduce you to the tutorial on installing and running Python under Windows 10 Atom. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
Related recommendations: "atom tutorial"
1. Download Atom
1. Official website: Atom official website
2. Open this webpage, you can see that Atom is for the operating system Windows7 or above version
3. Download is complete, double-click the exe
4. Loading interface
(1) First check in Settings whether has Python support
, blogger here Because the Python library is installed, Disable
is displayed (2) Click on the package name and we can also go to the web page to view related information about the package
2. Install Python’s IDE,
UI,# that are suitable for Atom ##Server and
(1) Open cmd and run the following instructions to install python-language-serverpip install python-language-server[all]
(2) Installation supports various language IDEs UI interface, search atom-ide-ui
atom-ide-ui
Install as shown in the picture
(3) Similarly, install ide-python
:ide-python
The most important, install the running toolatom-python-run
:Press F5 to run, F6 to pause~
(5) The final downloaded package can be seen in this file C:\Users\your computer username\.atom\packages
*3. Running code example
1. Here I use my Python to crawl and download Baidu pictures
2.打开这个项目,菜单栏里点击File->Add Project Folder
3.Atom里打开这个download_picture.py(以杉原杏璃为关键字)
# coding=utf-8 """ @author:nickhuang1996 """ import re import sys import urllib import requests import os import cv2 from glob import glob import time def getPage(keyword, times, page_number, pic_type): page = times * page_number#time每一次加一 keyword = urllib.parse.quote(keyword, safe='/')#对含有特殊符号的URL进行编码,使其转换为合法的url字符串。中文则转换为数字,符号和字母的组合 #print(keyword) url_begin = "http://image.baidu.com/search/" + pic_type + "?tn=baiduimage&ie=utf-8&word="#pic_type url = url_begin + keyword + "&pn=" +str(page) return url def get_onepage_urls(onepageurl): try: html = requests.get(onepageurl).text except Exception as e: print(e) pic_urls = [] return pic_urls pic_urls = re.findall('"objURL":"(.*?)",', html, re.S)#index是30个图片的链接,flip是60个 print("一共有{}个图片链接".format(len(pic_urls))) return pic_urls def download_pic(pic_urls, keyword, save_path): #给出图片链接列表, 下载所有图片 print("去除了重复的图片下载数量为:{}".format(len(pic_urls))) print("\n开始下载...") start_time = time.time() for i, pic_url in enumerate(pic_urls): try: pic = requests.get(pic_url, timeout=5) string = save_path + '/' + str(i + 1) + '.jpg' with open(string, 'wb') as f: f.write(pic.content) print('成功下载第%s张图片: %s' % (str(i + 1), str(pic_url))) except Exception as e: print('下载第%s张图片时失败: %s' % (str(i + 1), str(pic_url))) print(e) continue end_time = time.time()-start_time print("下载结束,耗时:{:.0f}m {:.0f}s...".format(end_time // 60, end_time % 60)) if __name__ == '__main__': keyword = '杉原杏璃' # 关键词, 改为你想输入的词即可, 相当于在百度图片里搜索一样 save_path = './baidu_download/' + keyword if not os.path.exists(save_path): os.mkdir(save_path) #参数设置 times = 0 #图片参数类型 pic_type = "flip"#"flip"/"index" print("图片链接关键字为:{}".format(pic_type)) page_number = 20#flip时为60,index时为30则不会有缓存 total_times = 3#请求总次数 """ 如果page_number为20,则百度图片每页显示20张图片,因此对于flip形式每页会多缓存(60-20=40)张,index形式每页会多缓存(30-20=10)张, 所以,请求4次的话: flip应该是 20 × 4 + (60 - 20) = 120张图片,而不是60×4 = 240 index应该是 20 × 4 + (30 - 20) = 90张图片,而不是30×4 = 120 示意图: flip index 0 ________ ______ 0 | | | | | 20 | | 20 | 10 | | | | 20 |______|______ |______|______ 20 | | | | | 20 | _|_ 20 | 30 | | | | 40 |______|______ |______|______ 40 | | | | | | | 20 | _|_ 20 | 50 | | | | | 60 _|_ |______|______ |______|______ 60 | | | | | | | 20 | _|_ 20 | 70 | | | | | 80 _|_ |______| |______| 80 | | | | | _|_ 90 | | 100 _|_ | | | | 120 _|_ 说白了,就是获取了重复的图片 可以通过调节page_number变量查看 """ all_pic_urls = [] while 1:#死循环 if times > total_times: break print("第{}次请求数据".format(times + 1)) url=getPage(keyword, times, page_number, pic_type)#输入参数:关键词,开始的页数,总页数 print(url)#打印链接 onepage_urls= get_onepage_urls(url)#index是30个图片的链接,flip是60个 times += 1#页数加1 if onepage_urls != 0: all_pic_urls.extend(onepage_urls)#列表末尾一次性追加另一个序列中的多个值 #print("将要下载的图片数量变为:{}".format(len(all_pic_urls))) print("下载的图片总量变为:{}".format(len(all_pic_urls))) download_pic(list(set(all_pic_urls)),keyword, save_path)#set去除重复的元素(链接)
效果如下(可以看到很多警告,也支持ctrl+鼠标访问函数和变量):
4.我们点击F5,可以看到程序运行成功!!
是不是用这个IDE也很不错呢~
更多编程相关知识,请访问:编程课程!!
The above is the detailed content of How to install and run Python in Atom under Win10 environment. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

To run Python code in Sublime Text, you need to install the Python plug-in first, then create a .py file and write the code, and finally press Ctrl B to run the code, and the output will be displayed in the console.

VS Code can run on Windows 8, but the experience may not be great. First make sure the system has been updated to the latest patch, then download the VS Code installation package that matches the system architecture and install it as prompted. After installation, be aware that some extensions may be incompatible with Windows 8 and need to look for alternative extensions or use newer Windows systems in a virtual machine. Install the necessary extensions to check whether they work properly. Although VS Code is feasible on Windows 8, it is recommended to upgrade to a newer Windows system for a better development experience and security.

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

VS Code can be used to write Python and provides many features that make it an ideal tool for developing Python applications. It allows users to: install Python extensions to get functions such as code completion, syntax highlighting, and debugging. Use the debugger to track code step by step, find and fix errors. Integrate Git for version control. Use code formatting tools to maintain code consistency. Use the Linting tool to spot potential problems ahead of time.
