Python publish module steps to share _python

Source: Internet
Author: User

1. Create a folder Nester for module Nester, which contains: nester.py (module file):

Copy Code code as follows:

"" "This is the" nester.py "module, which provides a function called the print_lol (),
function is to print list, temperament contains nested list "" "
def print_lol (the_list):
"" "This function takes a positional argument, named" The_list ", which can be any Python list
Each item of data in the specified list is output recursively to the screen, and the data items occupy one row ""
For Each_item in The_list:
If Isinstance (each_item,list):
Print_lol (Each_item)
Else:print (Each_item)

2. Create a new setup.py file in the Netster folder (containing the elements you want to publish):

Copy Code code as follows:

From Distutils.core Import Setup
Setup (name= ' Nester ',
Version= ' 1.0 ',
Py_modules= ' Nester ',
Author= ' Nidieya ')

3. Build the Publishing file:

"Head in the Python" is about the Linux environment in the release and construction of modules

The build module is experiencing problems under window:

If you enter Python in cmd, it does not show internal or external commands.

Add the Python installation directory to the system environment variable path. For example, installed in C:\Python33
My Computer icon right-click-> Properties-> advanced-> Environment variables

Open dialog box Double-click the path above, add C:\PYTHON33 to the column of the variable value, and note the semicolon;
The steps to release the module are available when the problem is resolved

Open the directory where Nester is located on the DOS command line
CD C:\nester I put it in the C root directory

Copy Code code as follows:

Python setup.py sdist


4. Post installation to your local Python copy

Copy Code code as follows:

Python setup.py Install


After the module is published, you can import it using the

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.