Create a Python local copy

Source: Internet
Author: User

You can avoid the case where the interpreter cannot find the module after creating the local copy.

1. Create a Test pl.py

1 def printtest (): 2     Print ("This isa test")

2. Place the pl.py into the PL folder and create another setup.py in the PL folder

1  fromDistutils.coreImportSetup2 3 Setup (4Name='PL',5Version ='1.0.0',6py_modules=['PL'],7Author='htest',8Author_email='[email protected]',9Url='http://www.test.com',Tendescription='This is a test', One)

3. Build the Release file-enter the PL directory and enter the Python setup.py in cmd sdist

1D:\python\test\pl>python setup.py sdist2 running Sdist3 running Check4Warning:sdist:manifest Template'manifest.in'Does notexist (using default file list)5 6Warning:sdist:standard file notFound:should has one of the README, README.txt7 8Writing manifest file'MANIFEST'9Creating pl-1.0. 0TenMaking Hard Linksinchpl-1.0. 0 ... OneHard Linking pl.py-pl-1.0. 0 AHard Linking setup.py-pl-1.0. 0 - Creating Dist -Creating'Dist\pl-1.0.0.zip'  andAdding'pl-1.0.0'To it theAdding'Pl-1.0.0\pkg-info' -Adding'pl-1.0.0\pl.py' -Adding'pl-1.0.0\setup.py' -removing'pl-1.0.0'( andEverything under it)

4. Create a local copy-also in the PL directory, and enter the Python setup.py install in cmd

1D:\python\test\pl>python setup.py Install2 Running Install3 Running Build4 running Build_py5 Creating Build6 Creating Build\lib7Copying pl.pyBuild\lib8 running Install_lib9Copying build\lib\pl.py-C:\Users\huangch\AppData\Local\Programs\Python\Python35\Lib\site-PackagesTenByte-compiling C:\Users\huangch\AppData\Local\Programs\Python\Python35\Libsite-packages\pl.py to Pl.cpython-35.pyc running Install_egg_info Writing C:\Users\huangch\AppData\Local\Programs\Python\Python35\Lib\ Site-packages\pl-1.0.0-py3.5.egg-info

5 Testing

Re-open an idle

1 Import PL 2 >>> pl.printtest ()3 is a test  //validation successful 4

After 6 of the content is complete, you can refer to PL in any of the py files. You can also upload pl to the PyPI community to share your code.

Create a Python local copy

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.