In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the knowledge of "how to configure virtual machine VM". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Imagine a situation where you operate your project on one platform, but you want to refine and run it on another, which is why Pycharm does a lot of work to support remote debugging.
Running a project on a virtual machine mainly involves the following steps:
(1) define a virtual framework define a virtual box
(2) you need to configure a remote interpreter configure a remote interpreter under the virtual framework.
(3) load the current project launch your script in the remote console in the remote console
1. Preparatory work
Make sure your Pycharm already has the following environment:
(1) Oracle's Virtual Box is installed
(2) Vagrant is installed
(3) add these executables to the environment variable
The vagrant.bat file under the Vagrant installation file, which should be done automatically by the installer
The VBoxManage.exe file under the Oracle's VirtualBox installation file.
Make sure the Vagrant plug-in for Pycharm is available: click the Settings button in the main toolbar to open the Plugins page in the Settings dialog box, showing that the plug-in is available by default:
At this point, the preparatory work is completed and officially begins.
2. Create a virtual virtual box
In the Settings dialog box (click the Settings button on the main toolbar), click the Vagrant interface, and then enter the executable path and the instance path.
If the framework is predefined, the above options appear in a drop-down list, and you can select one of them:
If you do not currently have a suitable virtual box, you can add one by clicking the green plus sign, enter the frame name and download address:
Click OK,Pycharm to start automatically downloading the VM template:
At this point you have created a new virtual box and added it to the current environment.
Notice the Vagrant command under the Tool menu, which is associated with the standard Vagrant behavior.
Once you have created the Vagrant box, you need to initialize it under the project stub. Click Tools | Vagrant on the main menu, and select Init in Project Root:
Select the Vagrant box you are going 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 from the Vagrant menu):
Pycharm automatically runs the vagrant up command and displays the output in the console interface:
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 no interpreter is currently available, we need to click Configure Interpreters to customize one:
The Python Interpreters interface opens and click the green plus sign to select a remote interpreter:
In the Configure Remote Python Interpreter dialog box, server configuration is required. These settings can be set manually or imported from a defined Vagrant configuration file, and here we choose the second way. Clicking the Fill from Vagrant configuration button automatically populates the relevant setting property values based on the contents of the configuration file:
To confirm that the configuration is successful, click Test connection... Button:
Set it as the default interpreter:
From now on we can run all the script projects on the VM virtual machine:
Next we log in to virtual box through SSH.
4. Link the SSH terminal
Why do you need to log in? Because Pycharm asked you to.
Select Tools | Run SSH Terminal from the main menu, and if you define more than one host (host), select the one you want to link to (we choose the remote interpreter here):
Observe the console running information of the Run tool window window:
Now that you can interact directly with virtual box, let's first make sure that your project directory is fully mapped. Just look at the vagrant's default shared folder information:
Next, run an available script file, such as Solver.py:
The great task has been completed.
This is the end of "how to configure virtual machine VM". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.