Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install Atom and run Python in Win10 environment

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article is about how to install Atom and run Python in Win10 environment. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.

Download Atom

1. Official website: Atom official website

two。 When you open this page, you can see the version of Atom for the operating system Windows7 or above.

3. Download complete, double-click exe

4. Loading interface

II. Atom installs Python-related components

1. Check Python library support

(1) check whether Python is supported in Settings. Bloggers display Disable here because the Python library is installed.

(2) Click on the package name and we can also view the relevant information of the package on the web page.

two。 Install IDE, UI, Server, and running tools for Atom for Python

(1) Open cmd and run the following instructions to install python-language-server

Pip install python-language-server [all]

The installation successfully displays this interface:

(2) install the UI interface that supports IDE in various languages, and search atom-ide-ui in + Install

Atom-ide-ui

As shown in the figure

(3) similarly, install ide-python:

Ide-python

(4) Last and foremost, install the running tool atom-python-run:

Press F5 to run and F6 to pause ~

(5) the final downloaded package can be found in this file C:\ Users\ your computer user name\ .atom\ packages

* third, run the code example

1. Here I take my Python implementation to crawl and download Baidu pictures as an example: Python implements crawling and downloading Baidu pictures.

two。 To open the project, click File- > Add Project Folder in the menu bar

Open the download_picture.py in 3.Atom (with Sugihara Xingli as the keyword)

# coding=utf-8 "" @ author:nickhuang1996 "" import reimport sysimport urllib import requests import osimport cv2from globimport globimport time def getPage (keyword, times, page_number, pic_type): page = times * page_number#time add one at a time keyword = urllib.parse.quote (keyword, safe='/') # to encode URL with special symbols to convert it into a legal url string. Chinese is converted to numbers. Combination of symbols and letters # 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 is a link to 30 pictures, and flip is 60 print ("a total of {} picture links" .format (len (pic_urls) return pic_urls def download_pic (pic_urls, keyword, save_path): # give a list of picture links Download all pictures print ("number of downloads excluding duplicates is: {}" .format (len (pic_urls) print ("\ nstart downloading.") 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 (' successfully downloaded% s picture:% s% (str (I + 1), str (pic_url)) except Exception as e: print ('failed to download% s picture:% s% (str (I + 1)) Str (pic_url)) print (e) continue end_time = time.time ()-start_time print ("download ends Time consuming: {: .0f} m {: .0f} s... ".format (end_time / / 60, end_time% 60) if _ _ name__ = ='_ main__': keyword = 'Sugihara apricot glass' # keyword, change to the word you want to enter It is equivalent to searching for the same thing in Baidu images: save_path ='. / baidu_download/' + keyword if not os.path.exists (save_path): os.mkdir (save_path) # Parameter setting times = picture parameter type pic_type = "flip" # "flip" / "index" print ("picture link keyword is: {}" .format (pic_type)) 60 when page_number = 2 If index is 30, there will be no cache total_times = total number of requests "" if page_number is 20, Baidu images will display 20 pictures per page, so for flip format, there will be more cache per page (60-20cm 40), and for index form, there will be more cache per page (30-20mm 10). So, if you request 4 times: flip should be 20 × 4 + (60-20) = 120pictures. Instead of 60 × 4 = 240index, it should be 20 × 4 + (30-20) = 90 pictures. Instead of 30 × 4 = 120Diagram: 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 | _ | _ to be clear You can view "all_pic_urls = [] while 1if times # endless loop if times > total_times: break print (" data of the {} first request ".format (times + 1)) url=getPage (keyword, times, page_number, pic_type) # input parameters: keyword, number of starting pages by adjusting the page_number variable. Total number of pages print (url) # print link onepage_urls= get_onepage_urls (url) # index is a link to 30 pictures Flip is 60 times + = number of pages plus 1 if onepage_urls! = 0: all_pic_urls.extend (onepage_urls) # multiple values in another sequence are appended at the end of the list at once # print ("the number of pictures to be downloaded becomes: {}" .format (len (all_pic_urls) print ("the total number of downloaded pictures becomes: {}" ".format (len (all_pic_urls)) download_pic (list (set (all_pic_urls) Keyword, save_path) # set removes duplicate elements (links)

The effect is as follows (you can see many warnings, and ctrl+ mouse access functions and variables are also supported):

4. When we click on F5, we can see that the program runs successfully!

Is it good to use this IDE?

Thank you for reading! On the Win10 environment how to install Atom and run Python to share here, I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report