Home Development Tools atom How to install and run Python in Atom under Win10 environment

How to install and run Python in Atom under Win10 environment

Dec 11, 2020 pm 05:48 PM
atom python

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.

How to install and run Python in Atom under Win10 environment

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. Check Python library support

(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

running tools

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

1

<strong>pip install python-language-server[all]</strong>

Copy after login
Successful installation displays this interface:

(2) Installation supports various language IDEs UI interface, search atom-ide-ui

1

<strong>atom-ide-ui</strong>

Copy after login

in

Install as shown in the picture

(3) Similarly, install ide-python

:

1

<strong>ide-python</strong>

Copy after login

(4) Finally

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

For example: Python implements crawling and downloading Baidu pictures

2.打开这个项目,菜单栏里点击File->Add Project Folder

3.Atom里打开这个download_picture.py(以杉原杏璃为关键字)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

# 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=&#39;/&#39;)#对含有特殊符号的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(&#39;"objURL":"(.*?)",&#39;, 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 + &#39;/&#39; + str(i + 1) + &#39;.jpg&#39;

             

            with open(string, &#39;wb&#39;) as f:

                f.write(pic.content)

                print(&#39;成功下载第%s张图片: %s&#39; % (str(i + 1), str(pic_url)))

  

        except Exception as e:

            print(&#39;下载第%s张图片时失败: %s&#39; % (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__ == &#39;__main__&#39;:

    keyword = &#39;杉原杏璃&#39;  # 关键词, 改为你想输入的词即可, 相当于在百度图片里搜索一样

    save_path = &#39;./baidu_download/&#39; + 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去除重复的元素(链接)

Copy after login

效果如下(可以看到很多警告,也支持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!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP and Python: Code Examples and Comparison PHP and Python: Code Examples and Comparison Apr 15, 2025 am 12:07 AM

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

How to train PyTorch model on CentOS How to train PyTorch model on CentOS Apr 14, 2025 pm 03:03 PM

Efficient training of PyTorch models on CentOS systems requires steps, and this article will provide detailed guides. 1. Environment preparation: Python and dependency installation: CentOS system usually preinstalls Python, but the version may be older. It is recommended to use yum or dnf to install Python 3 and upgrade pip: sudoyumupdatepython3 (or sudodnfupdatepython3), pip3install--upgradepip. CUDA and cuDNN (GPU acceleration): If you use NVIDIAGPU, you need to install CUDATool

How is the GPU support for PyTorch on CentOS How is the GPU support for PyTorch on CentOS Apr 14, 2025 pm 06:48 PM

Enable PyTorch GPU acceleration on CentOS system requires the installation of CUDA, cuDNN and GPU versions of PyTorch. The following steps will guide you through the process: CUDA and cuDNN installation determine CUDA version compatibility: Use the nvidia-smi command to view the CUDA version supported by your NVIDIA graphics card. For example, your MX450 graphics card may support CUDA11.1 or higher. Download and install CUDAToolkit: Visit the official website of NVIDIACUDAToolkit and download and install the corresponding version according to the highest CUDA version supported by your graphics card. Install cuDNN library:

Detailed explanation of docker principle Detailed explanation of docker principle Apr 14, 2025 pm 11:57 PM

Docker uses Linux kernel features to provide an efficient and isolated application running environment. Its working principle is as follows: 1. The mirror is used as a read-only template, which contains everything you need to run the application; 2. The Union File System (UnionFS) stacks multiple file systems, only storing the differences, saving space and speeding up; 3. The daemon manages the mirrors and containers, and the client uses them for interaction; 4. Namespaces and cgroups implement container isolation and resource limitations; 5. Multiple network modes support container interconnection. Only by understanding these core concepts can you better utilize Docker.

Python vs. JavaScript: Community, Libraries, and Resources Python vs. JavaScript: Community, Libraries, and Resources Apr 15, 2025 am 12:16 AM

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

How to choose the PyTorch version under CentOS How to choose the PyTorch version under CentOS Apr 14, 2025 pm 02:51 PM

When selecting a PyTorch version under CentOS, the following key factors need to be considered: 1. CUDA version compatibility GPU support: If you have NVIDIA GPU and want to utilize GPU acceleration, you need to choose PyTorch that supports the corresponding CUDA version. You can view the CUDA version supported by running the nvidia-smi command. CPU version: If you don't have a GPU or don't want to use a GPU, you can choose a CPU version of PyTorch. 2. Python version PyTorch

How to do data preprocessing with PyTorch on CentOS How to do data preprocessing with PyTorch on CentOS Apr 14, 2025 pm 02:15 PM

Efficiently process PyTorch data on CentOS system, the following steps are required: Dependency installation: First update the system and install Python3 and pip: sudoyumupdate-ysudoyuminstallpython3-ysudoyuminstallpython3-pip-y Then, download and install CUDAToolkit and cuDNN from the NVIDIA official website according to your CentOS version and GPU model. Virtual environment configuration (recommended): Use conda to create and activate a new virtual environment, for example: condacreate-n

How to install nginx in centos How to install nginx in centos Apr 14, 2025 pm 08:06 PM

CentOS Installing Nginx requires following the following steps: Installing dependencies such as development tools, pcre-devel, and openssl-devel. Download the Nginx source code package, unzip it and compile and install it, and specify the installation path as /usr/local/nginx. Create Nginx users and user groups and set permissions. Modify the configuration file nginx.conf, and configure the listening port and domain name/IP address. Start the Nginx service. Common errors need to be paid attention to, such as dependency issues, port conflicts, and configuration file errors. Performance optimization needs to be adjusted according to the specific situation, such as turning on cache and adjusting the number of worker processes.

See all articles