The old driver takes you with vagrant. Create a one-stop Python development test environment

Source: Internet
Author: User
Tags virtual environment lenovo desktop

Objective

As a learning and use of Python's old driver, it seems that should often summarize a little things, so that the new driver as soon as possible, less detours, and then everyone together happy play.
Today, let's use vagrant with Xshell to create a one-stop Python development test environment.

Objective

Allows you to debug python in a Linux environment happily under Windows.

    • Applicable crowd: Python Novice and small partners who want to debug Python under Windows using Linux environment.

    • Difficulty: Super easy

    • Final effect: Use only one Xshell terminal (other similar can), launch Ubuntu virtual machine, Python2 and PYTHON3 environment arbitrarily switch, bring the folder with Windows share.

Benefits
    1. Vagrant shared folder is provided by default to quickly test Python code in Ubuntu environment

    2. Both local and Ubuntu systems can be edited and modified to synchronize code in real time

    3. Before starting the virtual environment, do not need to open vmvare or VirtualBox, etc., directly in the Shell Environment Command!

    4. Vagrant's virtual environment is lighter and consumes less memory, resulting in the same virtualization effect

    5. Easy to migrate, directly package box files, copy and paste just fine

    6. New virtual environment Convenient, after the Add box, you can create a new folder, directly inside the init box name, and then vagrant up to quickly start a new environment

Steps

Note: Please download all the required software according to my download link first.

Vagrant Package Download Path:
Link: Http://pan.baidu.com/s/1hsLNOvM Password: 4698

1. Installing VirtualBox
are directly next, the specific process is slightly.

2. Install vagrant, you need to restart the computer after completion, please close the save important programs and data in advance
Note: Restart time please go to the boot interface to see if you have started CPU virtualization, generally by F2, or F12, or directly delete, depending on your computer brand decision, such as Lenovo Desktop is F12.
If you have already installed other virtual machines and can run correctly, ignore this step.

3. Installing Xshell
or other terminal software, slightly. Just pick one you like.

4. Install Ubuntu using vagrant

4.1 Using an existing box image (recommended)
In Xshell default terminal new folder, such as Ubuntu as the path of the virtual machine, note here is directly you can synchronize the path of data!

New folder, here I was in the C packing directory, established vaVms\ubuntu64 :
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/152871/201607/152871-20160718145348857-211657121. PNG "style=" border:0px; "/>
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/152871/201607/152871-20160718145412982-2036089231. PNG "style=" border:0px; "/>

Then copy the Ubuntu-trusty-64.box to the current folder, and the cmd command into the current folder:
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/152871/201607/152871-20160718145413591-1701706894. PNG "width=" "height=" 151 "style=" border:0px; "/>

[c:\vavms\ubuntu64]$ DIR in Drive C is the serial number of the new volume volume is the Cc79-1bf3c:\vavms\ubuntu64 directory 2016/07/0717:51<dir>.2016/07/ 0717:51<dir>, .... 2016/07/0717:48484,678,037 ubuntu-trusty-64.box1 files 484,678,037 bytes 2 directories 57,693,339,648 free bytes

  

To add an image file:

1 [c:\vavms\ubuntu64]$ vagrant Box Add ubuntu64 ubuntu-trusty-64.box 2 3 ==> Box:box file is not detected as metadata . Adding it directly ... 4 5 ==> box:adding box ' ubuntu64 ' (v0) for Provider:6 7 box:unpacking necessary Files from:file://c:/vavms/ubuntu64/u Buntu-trusty-64.box 8 9 box:10 ==> box:successfully added box ' ubuntu64 ' (v0) for ' VirtualBox '!

To view the image files that have been added to the local:

[c:\vavms\ubuntu64]$ vagrant Box Listubuntu64 (virtualbox,0)

Initialize the image, this is the new boot file in the current folderVagrantfile

[c:\vavms\ubuntu64]$ vagrant init ubuntu64a ' vagrantfile ' has been placed inthis directory. You're nowready to ' vagrant up ' your first virtual environment! Please readthe comments in the Vagrantfileas well as documentation on ' vagrantup.com ' for more information on usingvagrant.

650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/152871/201607/152871-20160718145414747-954254796. PNG "width=" "height=" 172 "style=" border:0px; "/>

Start a virtual machine

[c:\vavms\ubuntu64]$ vagrant up

Then you will see the next few lines are prompted to tell you which port can log on to this machine such as

Default:forwarding ports...default:22 (Guest) =>2222 (host) (Adapter 1) ==>default:booting Vm...==>default: Waitingfor machine to boot. This could take a few minutes...default:ssh address:127.0.0.1:2222

Then select the file in the Xshell-new, then enter the hostname, such as Va-ubuntu, Host 127.0.0.1, Port 2222, and then select the User authentication node on the left tree of the interface, enter the user name password, are vagrant, click on the bottom to determine, and then connect the machine. hahaha, you can see the effect!
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/152871/201607/152871-20160718145415888-1908207638. PNG "style=" border:0px; "/>
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/152871/201607/152871-20160718145416638-931350764. PNG "style=" border:0px; "/>

Supplement
If the second one is started, the second port of the other box,2222 is automatically assigned to 2200,2201,2202 and the like, you need to be aware of the connection. You'll see a hint like this after vagrant up:

==>default:fixed Port Collision For22=>2222.now on port 2203.==>default:clearing any previously set network inte Rfaces...==>default:preparing network interfaces based on Configuration...default:adapter1:nat==>default: Forwarding ports...default:22 (Guest) =>2203 (host) (Adapter 1)

You can create a system of N requirements:
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/152871/201607/152871-20160718145417326-1880429129. PNG "style=" border:0px; "/>

4.2 Download the box image online (it is possible to ignore this step, which is used for downloading images online.) )

Ubuntuvagrant init ubuntu/trusty64vagrant up--provider virtualbox centos6vagrant init bento/centos-6.7vagrant up-- Provider VirtualBox centos7vagrant init bento/centos-7.2vagrant up--provider VirtualBox

5. Happy Test python

[Email protected]:~$ df-hfilesystemsizeusedavailuse%mounted Onudev 241m12k241m1%/devtmpfs 49M348K49M1%/run/dev/sda1 40g1.6g37g5%/none 4.0k04.0k0%/sys/fs/cgroupnone 5.0m05.0m0%/run/locknone 245m0245m0%/run/shmnone 100M0100M0%/run/ Usernone 150g99g51g67%/vagrant

This is the local and virtual machine share path.

[Email protected]:~$ [email protected]:~$ cd/vagrant[email protected]:/vagrant$ lsubuntu-trusty-64.boxvagrantfile[ Email protected]:/vagrant$ Touch Test.py[email protected]:/vagrant$ lstest.py ubuntu-trusty-64.boxvagrantfile

Test the folder share, to see in Windows, is not more than the test.py file:
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/152871/201607/152871-20160718145418091-1122785521. PNG "style=" border:0px; "/>
Of course, here, you can use any of your favorite editor, open the editor, and then go back to Ubuntu view, real-time synchronization of Oh!

For example Sublime open edit:
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/152871/201607/152871-20160718145418763-1445856221. PNG "width=" "height=" 214 "style=" border:0px; "/>
Run?
Of course, no problem!
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/152871/201607/152871-20160718145419654-1582326101. PNG "style=" border:0px; "/>

Keep in mind that the UBUNTU14 version is supported for multiple versions.
Python look, the default should be 2.7, try Python3, you should see the python3.4 interface.

1 [Email protected]:/vagrant$ python 2 3 Python2.7.6 (DEFAULT,JUN222015,17:58:13) 4 5 [GCC 4.8.2] on linux2 6 7 Type "Hel P "," copyright "," credits "or" license "for more information. 8 9 >>>10 [email protected]:/vagrant$ python312 Python3.4.3 (default,oct142015,20:28:29) [GCC 4.8.4] O n linux16 Type "Help", "copyright", "credits" or "license" for more information.18 >>>

OK, let's go here and have a good time!
Believe me, on the way to Python, you are not alone!


The old driver takes you with vagrant. Create a one-stop Python development test environment

Related Article

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.