Pycharm tutorial (7) Virtual Machine VM configuration tutorial, pycharmvm

Source: Internet
Author: User

Pycharm tutorial (7) Virtual Machine VM configuration tutorial, pycharmvm

Imagine a situation where you operate your project on one platform, but you want to improve and run it on another platform, this is why Pycharm has done a lot of work to support remote debugging.

To run a project on a virtual machine, perform the following steps:

(1) define a virtual framework define a virtual box

(2) You need to configure a remote interpreter under the virtual framework.

(3) load the current project launch your script in the remote console

1. Preparations

Make sure your Pycharm has the following environments:

(1) Installing Oracle's Virtual Box

(2) Vagrant is installed.

(3) add these executable files to the environment variables.

The Vagrant. bat file under the vagrant installation file, which should be automatically completed by the installer

The vboxmanage.exe file under the Oracle's virtualboxinstallation file.

Ensure that Pycharm'sVagrantPlug-in availability: Click the Settings button in the main toolbar to open the Plugins page in the Settings dialog box, showing the default available plug-in:

Now the preparation is complete and the process begins.

2. Create a virtual box

In the Settings dialog box (click the Settings button in the main toolbar), click the Vagrant interface, and enter the executable file path and instance path.

If the framework has been pre-defined, the above options will appear in a drop-down list. select one of them:

If there is no suitable virtual box, you can click the green plus sign to add one, enter the framework name and:

Click OK and Pycharm starts automatically downloading the VM template:

Now you have created a new virtual box and added it to the current environment.

Note:ToolUnder the menuVagrantCommand, which is associated with the standard Vagrant behavior.

Once a Vagrant box is created, it needs to be initialized under the project stub. ClickTools | Vagrant,SelectInit in Project Root:

Select the Vagrant box you want to initialize:

At this time, the corresponding Vagrantfile will be created and can be changed as required:

After the initialization is complete, run the vagrant up commandVagrantSelectUpCommand ):

Pycharm runs automaticallyVagrant upCommand, and the output result is displayed on the console interface:

3. Configure the remote interpreter on the VM.

Open the Setting dialog box again (click the setting button on the main toolbar) and select the Project Interpreter page. Here you can select a corresponding Interpreter from the drop-down list, however, if no interpreter is available, clickConfigure InterpretersCustomize one:

The Python Interpreters interface is displayed. Click the green plus sign to select a remote Interpreter:

InConfigure Remote Python InterpreterIn the dialog box, configure the server. These settings can be set manually or imported from the defined Vagrant configuration file. Here we select the second method. Click the Fill from Vagrant configuration button to automatically Fill in the attribute values according to the configuration file content:

To confirm whether the configuration is successful, clickTest connection...Button:

Set it as the default Interpreter:

From now on, we can run all script projects on the vmvm:

Next, we use SSH to log on to the virtual box.

4. Connect to the SSH Terminal

Why do I need to log on? Because Pycharm requires you to do this.

SelectTools | Run SSH TerminalIf you have defined more than one host, select the one you want to establish the link (Here we choose remote interpreter ):

Observe the running information of the console in the Run tool window:

Now you can directly interact with virtual box. First, check whether your project directory is fully mapped. You only need to observe the default Shared Folder Information of vagrant's:

Next, run an available script file, such as Solver. py:

Success.

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.