Building modules and packaged and released into the use of

Use of the environment

Python 2.7.3 -- EPD_free 7.3-2 (32-bit)

PyCharm 2017.3.4 (Community Edition)
Build #PC-173.4674.37, built on March 6, 2018
JRE: 1.8.0_152-release-1024-b15 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 7 6.1

1. Prepare release

First, create a folder for the module, copy will be released ** py file into this folder;

Create a file called setup.py new file in the folder

E.g:

New nester folder, there are LL.py and setup.py.

 

 

 

# LL.py 
# Coding: UTF-. 8 
'' ' which is a LL.py module, provides a function, a print function returns a list, which may include nested list ' '' 
DEF print_lol (the_list):
     ' '' the output of each of the specified data item recursive list on the screen, each data row for '' ' 
    for each_item in the_list:
         IF (the isinstance (each_item, list)):
            print_lol(each_item)
        else:
            print(each_item)
#setup.py
from distutils.core import setup

setup(
    name='LL',
    version ='1.0.0',
    py_modules=['LL'],
    author='hfpython',
    author_email='aaa',
    url = ' HHH ' ,
    description='222'
)

2. Construction of publication

Open a terminal window in nester, type the command:

python setup.py sdist

 

 

 

 Installation will be released to the local copy python

python setup.py  install

 

 

 Published Glance

 

 

 Import module and use

After the terminal through the pip installed package, when the package is introduced into pycharm still being given. Novice do not know what the specific reason, I put my resolve to issue process, the main reason is pip install the package to "1 interpreter," but we project using the "interpreter 2." Our novice and more afraid of the word, so why do not back up, pick a suitable program on the line.

Solution one:

In Pycharm in, open the File ---> Settings, pop in the following figure:

Right click on "+" sign, enter their need to import the package name in the list below you can see the package they need

Finally, click Install Package, you can wait for the installation to complete.

Solution two:

Provided that the package has been successfully installed in the terminal by pip install command. Windows environment, pip download third-party packages will be stored in the following path: [your path] \ Python36 \ Lib \ site-packages \, under this folder, find the package we want to refer to, Copy to: [Use interpreter path] \ Lib \ site-packages \ under, can be used. Use your explanation is following this project, as shown. 

Solution three:

Time to re-build the project to create the check "inherit global site-packages", can be solved. For details, see figure below

 

 Then you can use!

【转】https://blog.csdn.net/kouyi5627/article/details/80531442

 

Guess you like

Origin www.cnblogs.com/sggggr/p/12006621.html