from:http://blog.csdn.net/u013088062/article/details/50170551
Virtual Environment Configuration
Configuring the Remote Interpreter
Imagine a situation where you operate your project on one platform , but you want to refine and run it on a different platform , which is why Pycharm does a lot of work to support remote debugging.
Virtual Environment Configuration
Running a project on a virtual machine consists mainly of the following steps:
(1) Defining a virtual framework define a Vsan (2) requires a remote interpreter to be configured under a virtual framework configure a Remotes interpreter (3) loading the current project in the remote console launch your script in T He remote console
1. Preparatory work
Make sure your pycharm already has the following environment:
(1) installed Oracle's virtual Box (2) installed vagrant //<----can be used to manage multiple virtual machines (VMS) (3) in a single physical machine program add these executables to environment variables Vagrant the Vagrant.bat file under the installation file, this part of the work should be done automatically by the Setup program under the Oracle's VirtualBox installation file under the VBoxManage.exe file.
Make sure that the Pycharm Vagrant plugin is available: Click the Settings button in the main toolbar, open the Plugins page in the Settings dialog box, and show that the plugin is available by default:
At this point, the preparation is completed and officially begins.
2. Create a virtual box
In the Settings dialog box (click the Settings button on the main toolbar), click the Vagrant interface, and then enter the path to the executable file and the instance path.
If the frame is already pre-defined, the item will appear in a drop-down list, selecting one from it:
If you do not currently have a suitable virtual box, you can add one by clicking the green plus sign and entering the frame name and:
Click Ok,pycharm to start the automatic download of VM templates:
You have now created a new virtual box and added it to your current environment .
Note the Vagrant command under the Tool menu, which is associated with the standard Vagrant behavior.
Once the Vagrant box is created, it needs to be initialized under the project stub. On the main menu, click Tools | Vagrant, Select Init in Project Root:
Select the Vagrant box you want to initialize:
The corresponding Vagrantfile file is created and can be changed as required:
After initialization is complete, execute the Vagrant up command (select the UP command in the Vagrant menu):
Pycharm will automatically run the vagrant up command and display the output in the console interface:
Configuring the remote interpreter
3. Configure the remote interpreter on the virtual machine
Open the Settings dialog again (click the Settings button on the main toolbar) and select the Project interpreter page, where you can select a corresponding interpreter from the drop-down list.
But if there are no interpreters currently available, we need to click Configure Interpreters to customize one:
The Python interpreters interface opens, click the Green plus sign to Select a remote interpreter :
In the Configure Remote Python Interpreter dialog box, the server configuration is required. These settings can be set manually or imported from a vagrant configuration file that has already been defined, where we choose the second way.
Clicking the fill from Vagrant Configuration button will automatically populate the relevant settings property values based on the contents of the configuration file:
In order to confirm whether the configuration was successful, click Test Connection ... Button:
Set it as the default interpreter:
From now on, we can run all of the script projects on VM virtual machines :
Next we'll log in to Virtual box via SSH.
4. Link SSH terminal
Why do I need to log in? Because Pycharm asked you to do this.
Select Tools from the main menu | Run SSH Terminal, if you have defined more than one host, select the one you want to create the link (we choose the Remote interpreter here):
Observe the console run information for the Run tool window windows:
Now that you've been able to interact directly with virtual box , let's first confirm that your project catalog is fully mapped. Simply observe the vagrant's default shared folder information:
Next, run an available script file, such as solver.py:
Done.
[Python] Remote Debugging by Pycharm