The latest PyCharm installation detailed tutorial

Contents
1. Introduction to
PyCharm and its download website
2. Click Downloads on the website to enter the second-level page and select the corresponding operating system to download PyCharm
3. Installation and configuration of PyCharm installer 1.
Run PyCharm Setup
2. Set the installation location
3. Installation option setting
4. Folder setting of PyCharm shortcut in the start menu
5. Installation
6. After installation, import PyCharm setting file 7.
After installation, activate PyCharm
8. After installation, PyCharm setting before starting PyCharm
9. Installation After that, the New Project environment configuration (including Python Interpreter
configuration) before starting PyCharm 10. After installation, the Open project and the configuration when the Python Interpreter is wrong 4. About the installation of third-party libraries or modules of python

The latest PyCharm installation detailed tutorial

1. Introduction to PyCharm and its download site

       PyCharm is a Python IDE (Integrated Development Environment, integrated development environment) created by JetBrains, with a set of tools that can help users improve their efficiency when developing in the Python language. PyCharm provides code editing, debugging, syntax highlighting, Project management, code jump, intellisense, testing, auto-completion and other functions to help us develop projects more efficiently. PyCharm is a common development environment tool for Python professional developers and those just starting out.

      PyCharm not only supports Python, but also supports python-based template languages ​​(frameworks, such as: Django, Flask, etc.), JavaScript, CoffeeScript, TypeScript, Cython, SQL, HTML/CSS, AngularJS, Node.js, etc. After installing PyCharm, when we create a new file, there are many file type options in the pop-up menu, which are basically the language types supported by PyCharm. The pycharm download website is shown in Table 1-1.

Table 1-1 pycharm download site

pycharm download site

https://www.jetbrains.com/pycharm/

2. Click Downloads on the website to enter the secondary page and select the corresponding operating system to download PyCharm

       Open the pycharm download website in Table 1-1 above, as shown in Figure 2-1 below.

 Figure 2-1 PyCharm page

       Click the Downloads control on the page interface in Figure 2-1 to enter the PyCharm download interface in Figure 2-2, and select the corresponding operating system to download the PyCharm installer.

 Figure 2-2 PyCharm download

Left side of Figure 2-2:

System requirements

      System and hardware requirements for installing PyCharm.

Installation instructions

      Installation Notes.

Other versions

      Other PyCharm versions.

Third-party software

       Third-party software, software that is complementary to PyCharm.

Right side of Figure 2-2:

Professional

       PyCharm Professional Edition requires purchase and a 30-day free trial. Compared with the Community Edition, it has relatively complete functions.

Community

       PyCharm Community Edition, free of charge, compared with the Professional Edition, does not have features such as Web development, Python We framework, Python analyzer, remote development, support for databases and SQL, etc.

       Here we download the PyCharm Professional Edition (Professional) for the Windows system. Click Download in the red box in Figure 2-2 to download the professional version of PyCharm, which is suitable for 64-bit operating systems and based on 64-bit processors. For specific requirements, see System requirements in Figure 2-2.

3. Installation and configuration of PyCharm 's installer

1. Run PyCharm Setup

         Run the installation program of the professional version of PyCharm downloaded above, and the installation interface shown in Figure 3-1 below will appear.

 Figure 3-1 PyCharm installation

       Click Next in Figure 3-1 to enter the interface for setting the PyCharm installation location shown in Figure 3-2.

2. Installation location setting

 Figure 3-2 PyCharm installation location

      You can customize the installation path of PyCharm. After the setting is complete, click Next to enter the interface for setting the PyCharm installation options shown in Figure 3-3.

3. Install option settings

 Figure 3-3 PyCharm installation option settings

Create Desktop Shortcut

       After checking PyCharm, create a shortcut on the desktop, check this item.

Update Path Variable(restart needed)

       After checking Add "bin" folder to the PATH (add the bin folder to the system path), the system path variable will be updated after the computer is restarted. Check this item.

       System path variable, when the system is required to run a program without telling it the full path where the program is located, the system will not only look for the program under the current directory, but also go to the path specified in path to find the executable variable.

Update Context Menu

       After checking Add "Open Folder as Project", update the context menu, that is, in the folder after installation, the Open Folder as PyCharm Project option appears in the menu of the right mouse button, click this option to start PyCharm, in this folder Start as a project. If the folder is the folder where the project is located, the project will be opened. If the project does not exist in the folder, the project will be created automatically. Whether this item is checked can be determined according to the requirements. It is recommended to check it, which is convenient for viewing python files or automatically creating projects.

Create Associations

       After checking .py, create a python file associated with PyCharm, that is, .py script (script) files can be opened with PyCharm. In a computer, an executable file written in a certain format is called a script.

       All the options in Figure 3-3 can be checked, click next to enter the folder setting interface of the PyCharm shortcut in the start menu shown in Figure 3-4.

4. Folder settings for PyCharm shortcuts in the start menu

 Figure 3-4 The folder of the PyCharm shortcut in the start menu

       The default JetBrains folder in Figure 3-4, the JetBrains folder in the computer start menu will generate a PyCharm shortcut. Here you can use the default JetBrains folder, click Install to install, and enter the PyCharm installation progress interface shown in Figure 3-5.

5. Installation

 Figure 3-5 PyCharm installation progress

          Figure 3-5 After the installation progress is completed, the prompt interface showing that the PyCharm installation is complete and the computer needs to be restarted appears as shown in Figure 3-6.

 Figure 3-6 PyCharm installation complete

        In Figure 3-6, you can choose to restart the computer immediately, or manually restart the computer later. Here, choose to restart the computer immediately. After restarting the computer, when you double-click to start PyCharm, a prompt to import PyCharm settings will appear.

6. After installation, import the PyCharm settings file

        If it is detected that the computer has settings for installing PyCharm versions in the past, the import PyCharm settings interface shown in Figure 3-7 will appear, and the path of the past PyCharm setting files will be automatically displayed.

 Figure 3-7 Import PyCharm settings

Previous version

         By default, the previous PyCharm setting file is imported, and the path of the previous PyCharm setting file will be automatically displayed.

Config or installation directory

         Manually import PyCharm configuration or installation settings.

Do not import settings

         Settings are not imported.

        If it is not detected that there is a setting file for installing PyCharm in the past on the computer, the import PyCharm setting interface shown in Figure 3-8 will appear.

Figure 3-8 Import PyCharm settings

        The above interface is mainly used to import the existing PyCharm settings. If there is no PyCharm setting or the existing PyCharm settings are not imported, you can choose not to import.

        We choose Do not import settings (do not import settings), click OK, and the PyCharm and Plugins (Plugins) activation interface shown in Figure 3-9 appears.

7. After installation, activate PyCharm

       Figure 3-9 is the interface for PyCharm activation and plug-in (Plugins, Code With Me) activation. Here are several ways to activate PyCharm.

 Figure 3-9 PyCharm and Plugins (Plugins) activation

Activate PyCharm

       There are three activation methods for activating PyCharm. JB Account is activated by JB account, Activation code is activated by activation code, and License server is activated by license server authorization.

       If you choose JB Account activation, you need to log in to the JB account to obtain a license. If you choose Activation code activation, you need to enter the activation code. If you choose License server activation, you need to enter the server address.

Start trial

        If you choose to try PyCharm, you can try it for free for 30 days through the registered account.

        In Figure 3-9, select the Activation code of PyCharm to activate. After entering the activation code, click the Activate button to activate.

8. After installation, PyCharm settings before starting PyCharm

        After PyCharm is activated, preliminary settings of PyCharm can be made. After the activation is successful, close (Close) the activation interface and return to the PyCharm setting interface in Figure 3-10, there are Projects (project), Remote Development (remote development), Customize (customization), Plugins (plugins), learn PyCharm (resources study) option.

 Figure 3-10 PyCharm settings

Projects

       New Project (create a new project), open (open an existing project on this computer), Get from VCS (open an existing project from other platforms).

        version control (VC) version control tools, such as: Git is a free, open source distributed version control system.

Remote Development

        Remote development, through this setting, you can use SSH to remotely go to other hosts for project development.

Customize

       PyCharm's custom settings, you can set the appearance color of the PyCharm interface (Color theme), set the font size of the PyCharm window (IDE font), and set the shortcut key (Keymap) of PyCharm.

       The appearance of the PyCharm interface defaults to Darcula, which is a dark black interface, and the bright white interface can choose the option containing the word Light.

Plugins

       Installing PyCharm's plug-ins can enhance the functions or effects of PyCharm. To use the Chinese version of the PyCharm window, you can enter Chinese in the search box of this option, and click the install of the Chinese (Sinplified) Language Pack plug-in to install it.

Learn PyCharm

         Learning materials for PyCharm

       After installing PyCharm, in the interface in Figure 3-10, you can first set the Remote Development, Customize, and Plugins options according to your own needs, and then create or open the project in the Projects option, or you can directly choose the Projects option to create or Open the project.

9. After installation, the New Project environment configuration ( including Python Interpreter configuration) before starting PyCharm

       Note: After installing PyCharm, when configuring the python project environment, you must first download the python installer and install the python installer, because in the environment configuration, you need to call the python.exe file generated after python installation (that is, the python interpreter ), therefore, before installing PyCharm, python should be installed first.

      After installing PyCharm for the first time, if there is no existing project, we need to create a new project and set the environment of the project. Here we take the python project as an example. Click New Project on the right side of the Projects option in the interface in Figure 3-10 to enter the python Project environment configuration interface in PyCharm shown in Figure 3-11.

       Figure 3-11 shows that PyCharm supports various types of projects, such as: Pure Python, Django, FastAPI, Flask, etc. Here we choose the Pure Python project type for pure Python programming.

 Figure 3-11 python Project environment configuration in PyCharm

      The Python Interpreter (Python interpreter) environment has two basic forms: New environment using and Previously configured interpreter.

(1)New environment using

        Create a project with a new environment. For this item, you can choose four virtual environments: Virtualenv, Pipenv, Poetry, and Conda. These four virtual environments have different characteristics. The Virtualenv virtual environment comes with Pycharm. Others need to be downloaded before installing. It can be determined according to your own needs.

       The virtual environment can ensure the relative independence of projects and reduce the interference between projects or between projects and the system environment. Here, select Pycharm’s default New environment using Virtualenv, and the folder venv will be automatically generated. The venv folder is used to store the Virtualenv virtual environment built when creating the project. The venv folder saves the python interpreter (equivalent to copying from the installed python) , third-party libraries or modules installed in the virtual environment (which may be collectively referred to as packages).

        In Figure 3-11, the cc folder of the specified path in the red box in the location is the location where the python project is stored. The python program (.py) written in Pycharm is stored in the cc folder, and the automatically generated venv folder is also saved. Save it in the cc folder of this project directory. In addition, when creating, an .idea folder will be automatically generated in cc, which stores the version information and historical records of the project. For example: after closing pycharm, download Open it again to restore the last closed state.

       Base interpreter is the location of Python Interpreter (interpreter), that is, import the python.exe file in the path where python is installed, or import the path of python.exe in the existing virtual environment. Usually import the python.exe file in the path where python is installed. It is best to install Python before PyCharm is installed. In this location, the python interpreter path will be automatically imported. If Python is not installed, the address where Python is downloaded will be automatically imported.

      The following mentions importing the Interpreter (interpreter), which is to open the path where python.exe is located. python.exe is the interpreter of python, its function is to convert python code into bytecode and interpret execution. Note that python.exe is not a python installer, but a python installer (for example: python-3.11.1-amd64.exe) that is generated after installation. If you set the interpreter, put the python installer (for example: python- 3.11.1-amd64.exe) as the interpreter, and then use pycharm to run the python program, it will prompt Modify Setup, judging that python is not installed successfully.

       Check Inherit global site-packages , you can inherit the packages installed in the system interpreter, that is, you can use the packages in the python installation location, whether this item is checked or not can be determined according to your needs. The package here can be understood as a general term for third-party libraries or modules.

       Check Make available to all projects to make this virtual environment available to other projects. Whether this item is checked can be determined according to requirements.

       Note that the venv folder cannot already exist in the cc folder of the location path in the red box in Figure 3-11, otherwise, it will conflict with the location path of the New environment using option in Figure 3-11, and it will display Environment location directory is not empty, and cannot Click Create in Figure 3-11 to create the project environment. If there are other files in the cc folder, click Create in Figure 3-11, and the following dialog box will be prompted that the directory in Figure 3-12 is not empty.

 Figure 3-12 Prompt dialog box

         At this point, click Create from Existing Sources in Figure 3-12 to create a project.

        The environment under the python installation path is called the python system environment. The virtual environment is a relatively independent environment, but it still has a dependency relationship with the python system environment. For example, the interpreter (interpreter) of the virtual environment is dependent on the python system environment. The virtual environment is mainly used to use third-party libraries or modules independently (isolated from other environments), and to use other built-in or rely on the python system environment, such as: use the standard library (standard library, the library that comes with python installation, that is, Built-in library), which is in the python system environment.

(2)Previously configured interpreter

     The above is to create a virtual environment to configure the project environment. If you select the Previously configured interpreter (previously configured interpreter) in Figure 3-11, you will use the existing environment to configure the project environment and import the interpreter from it.

       Figure 3-13 selects the Previously configured interpreter to create a project. In this way, you need to manually import the python interpreter (python interpreter). You can manually import the path where python.exe in the installed python is located (that is, the path in the system environment), or Import the path of python.exe in the existing virtual environment.

 Figure 3-13 python Project environment configuration in PyCharm

         Click the position of the red arrow in Figure 3-13, and the import interpreter interface shown in Figure 3-14 appears. The following is to configure the project environment through the existing Virtualenv Environment or System Interpreter environment.

Use an existing virtual environment (Virtualenv Environment)

 Figure 3-14 Virtualenv Environment imports interpreter

       The Virtualenv virtual environment of the python project can be created through the Virtualenv Environment option in Figure 3-14, but the venv folder above will not be generated in the project folder, but the virtual environment that comes with python or the virtual environment of the existing project will be used environment.

       Select the Virtualenv Environment option in Figure 3-14, and import python.exe from the python installation path (that is, import interpreter from the python installation path). The usage of Make available to all projects is the same as above. Click OK in Figure 3-14 to create a project in the zz folder (the project location set in Figure 3-13 is zz), automatically generate the .idea folder in the zz folder, and save Pycharm in the zz folder The python program (.py) written in , but the venv folder of the virtual environment is not generated in the zz folder. For projects created in this way, the virtual environment is the virtual environment that comes with python. The installed third-party libraries or modules are all in the site-packages folder under the python installation path, and Pycharm can call this site-packages Third-party libraries or modules.

       In Figure 3-14, the interpreter of the existing virtual environment can also be imported. The location of the installed third-party library or module is related to its installation method. The virtual environment of the project created in this way is the virtual environment of the existing project. The usage features are similar to creating a new virtual environment above.

Use the existing python system environment/System Interpreter

      In Figure 3-15, select System Interpreter to import the interpreter (interpreter) interface. Select System Interpreter to import the interpreter, you can import the path of python.exe in the installed python, or import the path of python.exe in the existing virtual environment.

 Figure 3-15 System Interpreter imports interpreter

       System Interpreter uses the python system environment (the environment under the python installation path), without a virtual environment.

      Select the System Interpreter option in Figure 3-15, and import python.exe from the python installation path (that is, import interpreter from the python installation path). The project created in this way uses the system environment, and the third-party libraries or modules installed are all in the site-packages folder under the python path, and Pycharm can call the third-party libraries or modules in this site-packages. There is a .idea folder in the folder zz where the project is located (the project location set in Figure 3-13 is zz), and the python program (.py) written in Pycharm can also be saved.

       In fact, opening an empty folder with pycharm is to create a project according to the python system environment by default, which is the above form. If you find it troublesome to configure the virtual environment, you can choose this shortcut to create a project using the python system environment, which will be set to the interpreter of the python system environment by default.

       Selecting System Interpreter in Figure 3-15 can also import the interpreter of the existing virtual environment. The location of the installed third-party library or module is related to its installation method. The project created in this way only uses the interpreter of the virtual environment. However, the system environment is still used, and other features are the same as above. Such imports are rarely used and will not be described here.

(3)Create a main.py welcome script

       In Figure 3-11, Create a main.py welcome script is checked by default, and a main.py script is created by default, that is, a python example is generated by default. This option is optional or not.

(4) Summary of environment configuration

       In the environment configuration, select New environment using to maintain the independent environment of the project and reduce interference. The third-party library or module installed or called is in the folder of the project, but the third-party library or module under the python path cannot be called. Selecting Previously configured interpreter does not necessarily guarantee an independent project environment, but if you import and install the interpreter under the python path, the third-party library or module installed or called is in the folder under the python path.

       If the requirements for environmental independence are very high, it is recommended to choose New environment using. If the requirements for environmental independence are not high, you can choose Previously configured interpreter to import and install the interpreter under the python path. In this way, the third-party library or module is in the python path In the folder below, the effect of multiple projects sharing third-party libraries or modules is achieved. The most common effect of this effect is to choose System Interpreter to create a project. After the configuration is complete, click create to create a new project.

       So far, we have completed the configuration of the python project environment and created a new project. After the creation is completed, PyCharm will be started and run, and we can develop python programs.

10. After installation, the configuration of Open project and Python Interpreter error

9         above is to create a new project (New Project), we can also not create a new project, but open (Open) an existing project.

(1) Open ( open an existing project)

       Here we take the python project as an example. Click Open on the right side of the Projects option in the interface in Figure 3-10 to open the path of the folder where the python project is located, start and run PyCharm, and enter the interface for opening python projects in PyCharm as shown in Figure 3-16 below.

 Figure 3-16 pycharm open project

        Click the button in the red box in Figure 3-16 to expand or hide the display column of the Project on the left side of the PyCharm window. Figure 3-17 below expands the display bar of the Project on the left side of the PyCharm window, and the right side of the PyCharm window is the file display area.

 Figure 3-17 The display bar of the Project on the left side of the PyCharm window

       After we open the project with PyCharm, we can basically judge the environment configuration characteristics of the project according to the path of python interpreter, the folder name generated by the folder where the project is located, and the knowledge of the environment configuration method mentioned in 9 above. We can view the path of the python interpreter in the title bar of PyCharm File→Settings→Project:→Python Interpreter, or in the first line of the Run window that pops up when running the code, we can see the path of the python interpreter.

        In fact, every time PyCharm starts, it will open the last created project by default.

        If you open a python file or run a python file in PyCharm, and an exception occurs in the Python Interpreter (python interpreter), you generally need to reconfigure (set) the python interpreter . The basic principle of configuration is the same as above, except that the configuration at this time is configured in the PyCharm interface.

(2) Configuration when Python Interpreter is wrong

       After opening the project, if it prompts Invalid Python interpreter selected for the project, that is, the python interpreter (python interpreter) used by the project is invalid, or the system cannot find the specified file, or the Python path appears in the Run window at the bottom of PyCharm when running the code program The abnormal prompt information of the configuration (usually caused by the inconsistency between the python version used by the project and the current computer version). These all mean to reconfigure the python interpreter, you can set a valid python interpreter (python interpreter) in PyCharm's title bar File→Settings→Project:→Python Interpreter.

     After opening the project, run a certain .py script (script) file directly. If PyCharm does not detect the python interpreter (python interpreter), the Edit Configuration editing configuration prompt shown in Figure 3-18 below will pop up.

 Figure 3-18 Edit configuration

       Select a valid python interpreter (python interpreter) from the drop-down menu in the red box in Figure 3-18, and click Run to run the .py script (script) file, but this configuration is only suitable for this .py file. To configure suitable for the entire project, you can set a valid python interpreter (python interpreter) in the title bar of PyCharm File→Settings→Project:→Python Interpreter.

       After opening the project, run a certain .py script (script) file directly. If the Invalid Python SDK prompt shown in Figure 3-19 below pops up, it is usually caused by the python version, which is not installed on the computer. The full name of SDK is Software Development Kit, software development kit, and Python SDK refers to the python development language tool.

 Figure 3-19 Invalid python development tools

       When the prompt in Figure 3-19 appears, click OK, and then set a valid python interpreter (python interpreter) in PyCharm's File→Settings→Project:→Python Interpreter, and then you can run this .py script (script) file.

       

         In addition, pycharm runs the program and prompts the Modify Setup question, as shown in Figure 3-20.

Figure 3-20 python modify setup

       The modify setup prompt in Figure 3-20 appears, generally because the python installer (for example: python-3.11.1-amd64.exe) is used as the interpreter when setting the interpreter, and then the python program is run with pycharm, it will prompt Modify Setup, it is judged that python is not installed successfully. The Python interpreter should be the python.exe generated after the python installer is installed. Therefore, when setting the interpreter, the python.exe file generated after the python installer is installed should be imported. You can reset the python interpreter (python interpreter) in PyCharm's File→Settings→Project:→Python Interpreter. 

        In PyCharm's title bar File→Settings→Project:→Python Interpreter

The configuration of the python interpreter (python interpreter) is basically similar to the method described in 9. above, and the description will not be repeated here.

4. About the installation of third-party libraries or modules of python

       When we write code, we often use third-party libraries or modules. Python has built-in third-party libraries or modules. You don’t need to install them, just import and use them. If we want to use non-built-in ones, we need to install third-party libraries or modules in advance. mold.

        Above we often mentioned the installation location of third-party libraries or modules (which can be collectively referred to as packages). The installation location of the third-party library or module is finally installed in the site-packages folder under the python installation path (that is, the site-packages in the system environment) or in the site-packages folder in the virtual environment. It is related to the path or environment configuration. Therefore, it is easy to appear that the third-party library or module cannot be used after installation. For example, the project uses a virtual environment. We have installed the third-party library or module into the system environment. use.

       Therefore, we should understand the installation methods of several commonly used third-party libraries or modules. Combining with our configured environment and adopting an appropriate installation method, problems can be avoided and it is also easy to find problems. There are three ways to install third-party libraries or modules.

(1) CMD command window

        Use the win+r shortcut key (that is, Windows+R) to open the running window, enter cmd and confirm, open the cmd command window, enter the pip install library name in the default path, this third-party library or module (library or module), you can Collectively referred to as packages, they are generally installed in the ...\Lib\site-packages folder under the python installation path (that is, in the site-packages folder in the system environment). This method is the command window of windows to install. Uninstall can use pip uninstall library name.

(2) File→Settings

       After Pycharm is successfully installed, it can be installed through the settings (File→Settings) in the file menu in the title bar of pycharm. Start pycharm, here is to open the cc project by default, enter File→Settings→Project:cc→Python Interpreter, click the + pointed by the red arrow in Figure 4-1 below, search for the library name in the pop-up window and install it, the installed third party Libraries or modules are stored in the ...\Lib\site-packages folder under the path of the calling interpreter.

 Figure 4-1 Settings settings of pycharm

        The third-party libraries or modules available in the current configuration are shown under the red arrow on the right side of Figure 4-1. Use the + pointed by the red arrow in Figure 4-1 to install third-party libraries or modules, which are installed by default in the ...\Lib\site-packages folder under the path where the called interpreter is located.

(3) Pycharm's command terminal Terminal

        Third-party libraries or modules are installed into the project in the virtual environment, and you can also click the Terminal button at the bottom of Pycharm and enter commands in the window that appears. Start pycharm, click the Terminal pointed to by the red arrow in Figure 4-2 (usually at the bottom of the Pycharm window), enter the pip install library name in the window that appears, press Enter to install, and uninstall with pip uninstall library name.

 Figure 4-2 The bottom bar of pycharm

       The location of installing third-party libraries or modules using Terminal is related to the environment in which the project is created. It is easily affected by the configuration environment, and the error Defaulting to user installation because normal site-packages is not writeable may appear when installing third-party libraries or modules.

       (1) and (2) The two installation methods are relatively certain, and (3) is relatively close to the configuration environment, which is prone to errors.

The latest PyCharm basic use (1)------File (File) settings, management operations:

https://blog.csdn.net/thefg/article/details/128948361

Detailed installation tutorial of the latest VS Code (Visual Studio Code):

https://blog.csdn.net/thefg/article/details/131752996

The latest python installation detailed tutorial:

https://blog.csdn.net/thefg/article/details/128601410

Finally, you are welcome to like, bookmark, and follow!

Guess you like

Origin blog.csdn.net/thefg/article/details/128881507