- Hands-On Enterprise Automation with Python.
- Bassem Aly
- 445字
- 2021-06-18 19:22:24
Setting up a Python project inside PyCharm
Inside PyCharm, a Python project is a collection of Python files that you have developed and Python modules that are either built in or were installed from a third party. You will need to create a new project and save it to a specific location inside your machine before starting to develop your code. Also, you will need to choose the default interpreter for this project. By default, PyCharm will scan the default location on the system and search for the Python interpreter. The other option is to create a completely isolated environment, using Python virtualenv. The basic problem with the virtualenv address is its package dependencies. Let's assume that you're working on multiple different Python projects, and one of them needs a specific version of x package. On the other hand, one of the other projects needs a completely different version from the same package. Notice that all installed Python packages go to /usr/lib/python2.7/site-packages, and you can't store different versions of the same package. The virtualenv will solve this problem by creating an environment that has its own installation directories and its own package; each time you work on either of the two projects, PyCharm (with the help of virtualenv) will activate the corresponding environment to avoid any conflict between packages.
Follow these steps to set up the project:
- Choose Create New Project:

- Choose the project settings:

-
- Select the type of project; in our case, it will be Pure Python.
- Choose the project's location on the local hard drive.
- Choose the Project Interpreter. Either use the existing Python installation in the default directory, or create a new virtual environment tied specifically to that project.
- Click on Create.
- Create a new Python File inside the project:

-
- Right-click on the project name and select New.
- Choose Python File from the menu, then choose a filename.
A new, blank file is opened, and you can write a Python code directly into it. Try to import the __future__ module, for example, and PyCharm will automatically open a pop-up window with all possible completions available as shown in the following screenshot:

- Run your code:

-
- Enter the code that you wish to run.
- Choose Edit Configuration to configure the runtime settings for the Python file.
- Configure new Python settings for running your file:

-
- Click on the + sign to add a new configuration, and choose Python.
- Choose the configuration name.
- Choose the script path inside your project.
- Click on OK.
- Run the code:

-
- Click on the play button beside the configuration name.
- PyCharm will execute the code inside the file specified in the configuration, and will return the output to the terminal.
- TensorFlow Lite移動端深度學習
- Production Ready OpenStack:Recipes for Successful Environments
- 人臉識別原理及算法:動態人臉識別系統研究
- Python Data Analysis(Second Edition)
- iOS應用逆向工程(第2版)
- 劍指MySQL:架構、調優與運維
- 劍指Java:核心原理與應用實踐
- R語言與網絡輿情處理
- Getting Started with Eclipse Juno
- 新一代SDN:VMware NSX 網絡原理與實踐
- Visual Studio 2015高級編程(第6版)
- OpenCV with Python By Example
- Android應用開發深入學習實錄
- MySQL程序員面試筆試寶典
- 零基礎學C++(升級版)