Python Basic Notes Series 4: Tool Installation and Configuration

  This series of tutorials is for personal study notes. If you want to browse, you may need other programming language basics (such as C language), why? Because I am bad at writing, only I can understand it! !
  At the beginning, I didn't plan to write this tool, but later I found that in some cases, there will be some strange problems, which are recorded here.


  • I am using the python version of the windows 10 operating system for the environment foundation
    : python2.7 address --> https://www.python.org/downloads/ 
    Sublime Text3: address --> https://www.sublimetext.com/
  • Install the pit of python:
    you can download and install directly. It should be noted that when installing, you must check pip (not checked by default) and Add python.exe to Path to ensure that third-party modules can be installed later and the path can be added to the windows system. environment variables.
    Then enter python in the win+r-->cmd command line to display the python version, that is, the installation is successful.
    If you cannot use python through the python command after the installation is complete, it may be that the environment variable is not added automatically. In this case, you can manually add the python installation directory to the environment variable path. 
  • The pit of installing ipython:
    IPython is a python interactive shell, which is much easier to use than the default python shell, supports variable auto-completion, auto-indentation, supports bash shell commands, and has built-in many useful functions and functions. So beginners can pretend to play. The installation method is win+r-->cmd, directly enter pip install ipython, you need to connect to the Internet~ If the prompt command does not exist, there are two main reasons for the error. One is that you did not check to install pip when installing python, you may need to reinstall python , the other is that the python environment variables are not configured properly, just configure the environment variables.
  • Install sublimeText3: After downloading the installation package, you can install it directly, the activation code is
  • Install the sublime plug-in:
    Before installing the sublime plug-in, you need to install the package control component , and then install the plug-in directly online:
    1) sublimeCodeIntel plug-in
      Using the sublimeCodeIntel plug-in, you can automatically prompt python code, view system functions, and jump and track custom functions.
      Installation: Under the condition that the package control component is installed, Ctrl+shift+p type install packages, and then continue to type SublimeCodeIntel to install. Also need to configure: select Perference-Package Settings-SublimeCodeIntel-Settings-User, copy the following configuration:
     1 {
     2     "codeintel_language_settings": {
     3         "Python27": {
     4             "python27": "D:\\Python27\\python.exe",
     5             "codeintel_scan_extra_dir": [
     6                 "D:\\Python27\\Lib\\idlelib",
     7                 "C:\\WINDOWS\\SYSTEM32\\python27.zip",
     8                 "D:\\Python27\\DLLs", 
     9                 "D:\\Python27\\lib",
    10                 "D:\\Python27\\lib\\plat-win",
    11                 "D:\\Python27\\lib\\lib-tk",
    12                 "D:\\Python27", 
    13                 "D:\\Python27\\lib\\site-packages"],
    14             "codeintel_scan_files_in_project": true,
    15             "codeintel_selected_catalogs": []
    16         },
    17     }
    18 }

      Here, the python path needs to be defined according to its own installation path. The directory contained in codeintel_scan_extra_dir can be viewed in sys.path in python IDLE (which can be found in the directory where python is installed) , as shown below:

      If you are using Python3, don't forget to change Python27 to Python3. Finally Ctrl+s save and restart just fine.
    2) Configure local python in sublime text3 Sublime
      has a python compilation environment by default (it may also be called local, after all, it is so small), but if you do not configure local python, you will always use sublime to write python when you need to import packages later. The package cannot be found .
      Configuration: In the Sublime menu Tools-->Build System-->New Build System... enter the following code:

    1 {
    2  "cmd": ["python","-u","$file"],
    3  "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    4  "selector": "source.python",
    5  "encoding": "utf-8",
    6 }

      Then save it, pay attention to the file extension: .sublime-build, for example, here is MyPython.sublime-build, and the save path is generally under C:\Users\b6762\AppData\Roaming\Sublime Text 3\Packages\User, Then select the environment name MyPython just defined by yourself in Tools-->Build System-->. After selecting, you can also use Ctrl+B to directly use this environment to run.
      Note: The "encoding" in the above code: "utf-8" is the utf-8 parameter in this line. Many tutorials on the Internet say to check whether your system is this encoding. The way to check is to open the command prompt with win+r, and in the title Right-click on the bar and click on the property to see, as shown in the following figure:


      However, mine is 936. If I change it to "encoding": "cp936", garbled characters appear in the console of sublime text3 .

    3) After writing python in sublime text3, you cannot
      switch to the python compilation environment in the console input sublime, tools->build can compile and run python, that is, our commonly used shortcut key Ctrl+B. After this, the console will appear at the bottom. But this can only be output but not input in the console .
      Installation: Ctrl+shift+p type install packages, and then continue to type SublimeREPL to install. Then the operation for each compilation and running is: tools->sublimeREPL->python->python-Run current file. After clicking, a new page *REPL*[python] will appear, as a new console, you can input and output interaction.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324665743&siteId=291194637