赞
踩
from setuptools import find_packages, setup
python setup.py --help
python setup.py --help-commands
python setup.py build --help
python setup.py install --help
python setup.py develop --help
python setup.py install包括两步:python setup.py build, python setup.py install,这两步,可分开执行, 也可只执行python setup.py install, 因为python setup.py install总是会先build后install.
python setup.py build 是python编译这个module的过程, 这个过程比较复杂,最后会生成build文件夹。除去build过程后的install过程,就是复制build/lib文件到用户指定的lib库。
https://blog.csdn.net/yywan1314520/article/details/50457835
1.在安装某个库或包时,发现可以python setup.py install 和python setup.py develop两种方式来安装,这两种方法有什么不同?一直困扰着我,下面我们就来讨论下这个简单的问题
2.python setup.py install:主要是安装典型第三方包,这种包比较稳定,不再需要你去编辑、修改或是调试。
3.python setup.py develop:当你安装一个包后,这个包需要你不断修改,这样你就不得不重新安装,这时就采用这种安装方法。
例如以安装requests包为例。
1、如果用 pip install requests 安装requests模块,则会把requests依赖的其它库都安装上,不用再费力去安装依赖的库了。
2、如果用 python setup.py install 安装requests模块,还要手动去安装第三方依赖的模块,否则在import requests的时候会报错。
例如当执行 python setup.py install 后,显示安装成功。
执行import requests,提示错误信息:
ImportError: No module named 'urllib3'
然后你再下载urllib3模块,用python setup.py install 安装,安装成功后,再执行import requests ,提示错误信息:
ImportError: No module named 'chardet'
你重复上面的操作,用同样的方法安装chardet后,你再执行import requests ,提示错误信息:
ImportError: No module named 'certifi'
最后我放弃了,不知道request到底依赖了多少的包(通过看源码可知) 。
通过上面两种方法对比,建议直接用pip的方法进行安装,一次到位。
Editable pip setup.py
yes pip install -e . python setup.py develop
no pip install . python setup.py install
这个.表示在当前目录下面找setup.py文件
如果setup.py在liuhao里面,就需要使用pip install ./liuhao/
-e就是--editable
-e, --editable <path/url> Install a project in editable mode (i.e. setuptools "develop mode") from a local project path or a VCS url.
只需要这一个setup.py文件就可以安装下面的
liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$ tree
.
└── liuhao
└── setup.py
1 directory, 1 file
liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$ pip install ./liuhao/
Processing ./liuhao
Building wheels for collected packages: DCNv2
Building wheel for DCNv2 (setup.py) ... done
Created wheel for DCNv2: filename=DCNv2-0.1-cp37-cp37m-linux_x86_64.whl size=2972 sha256=7ce42fa9f4e0537b49446ae02d34f4060704fb0c1b31b7d95c44862db3bb3fd3
Stored in directory: /tmp/pip-ephem-wheel-cache-gc_pgq8e/wheels/e0/88/72/76ba75e305b4a20501b63b64cdc7a5db23a7b93b2dd7bcb9cd
Successfully built DCNv2
Installing collected packages: DCNv2
Successfully installed DCNv2-0.1
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$
#会在/home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib/python3.7/site-packages/生成:
_ext.cpython-37m-x86_64-linux-gnu.so
DCNv2-0.1.dist-info文件夹
#==========================================================================
#没有在/home/liuhao/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2/生成任何文件
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$ pip list
Package Version
-------------------- ------------------
DCNv2 0.1
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$ pip show dcnv2
Name: DCNv2
Version: 0.1
Summary: deformable convolutional networks
Home-page: https://github.com/charlesshang/DCNv2
Author: charlesshang
Author-email: UNKNOWN
License: UNKNOWN
Location: /home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib/python3.7/site-packages
Requires:
Required-by:
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$ python ./liuhao/setup.py install running install running bdist_egg running egg_info creating DCNv2.egg-info writing DCNv2.egg-info/PKG-INFO writing dependency_links to DCNv2.egg-info/dependency_links.txt writing top-level names to DCNv2.egg-info/top_level.txt writing manifest file 'DCNv2.egg-info/SOURCES.txt' reading manifest file 'DCNv2.egg-info/SOURCES.txt' writing manifest file 'DCNv2.egg-info/SOURCES.txt' installing library code to build/bdist.linux-x86_64/egg running install_lib running build_ext building '_ext' extension creating build creating build/lib.linux-x86_64-3.7 g++ -pthread -shared -B /home/liuhao/anaconda3/envs/mydetection_python3.7.3/compiler_compat -L/home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib -Wl,-rpath=/home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib -Wl,--no-as-needed -Wl,--sysroot=/ -L/usr/local/cuda/lib64 -lcudart -o build/lib.linux-x86_64-3.7/_ext.cpython-37m-x86_64-linux-gnu.so creating build/bdist.linux-x86_64 creating build/bdist.linux-x86_64/egg copying build/lib.linux-x86_64-3.7/_ext.cpython-37m-x86_64-linux-gnu.so -> build/bdist.linux-x86_64/egg creating stub loader for _ext.cpython-37m-x86_64-linux-gnu.so byte-compiling build/bdist.linux-x86_64/egg/_ext.py to _ext.cpython-37.pyc creating build/bdist.linux-x86_64/egg/EGG-INFO copying DCNv2.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO copying DCNv2.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying DCNv2.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO copying DCNv2.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt zip_safe flag not set; analyzing archive contents... __pycache__._ext.cpython-37: module references __file__ creating dist creating 'dist/DCNv2-0.1-py3.7-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it removing 'build/bdist.linux-x86_64/egg' (and everything under it) Processing DCNv2-0.1-py3.7-linux-x86_64.egg creating /home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib/python3.7/site-packages/DCNv2-0.1-py3.7-linux-x86_64.egg Extracting DCNv2-0.1-py3.7-linux-x86_64.egg to /home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib/python3.7/site-packages Adding DCNv2 0.1 to easy-install.pth file Installed /home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib/python3.7/site-packages/DCNv2-0.1-py3.7-linux-x86_64.egg Processing dependencies for DCNv2==0.1 Finished processing dependencies for DCNv2==0.1 (mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$
#会在/home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib/python3.7/site-packages/生成:
DCNv2-0.1-py3.7-linux-x86_64.egg文件夹(里面有_ext.cpython-37m-x86_64-linux-gnu.so)
easy-install.pth
#==========================================================================
#会在/home/liuhao/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2/生成:这个不在liuhao文件夹里面
build文件夹(里面有_ext.cpython-37m-x86_64-linux-gnu.so)
DCNv2.egg-info文件夹
dist文件夹
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$ pip list
Package Version
-------------------- ------------------
DCNv2 0.1
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$ pip show dcnv2
Name: DCNv2
Version: 0.1
Summary: deformable convolutional networks
Home-page: https://github.com/charlesshang/DCNv2
Author: charlesshang
Author-email: UNKNOWN
License: UNKNOWN
Location: /home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib/python3.7/site-packages/DCNv2-0.1-py3.7-linux-x86_64.egg
Requires:
Required-by:
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$ pip install -e ./liuhao/
Obtaining file:///home/liuhao/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2/liuhao
Installing collected packages: DCNv2
Running setup.py develop for DCNv2
Successfully installed DCNv2
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$
#会在/home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib/python3.7/site-packages/生成:
easy-install.pth
DCNv2.egg-link
#==========================================================================
#会在/home/liuhao/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2/liuhao/生成:
build文件夹(里面有_ext.cpython-37m-x86_64-linux-gnu.so)
DCNv2.egg-info文件夹
_ext.cpython-37m-x86_64-linux-gnu.so
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$ pip list
Package Version Location
-------------------- ------------------ --------------------------------------------------------------------------------
DCNv2 0.1 /home/liuhao/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2/liuhao
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$ pip show dcnv2
Name: DCNv2
Version: 0.1
Summary: deformable convolutional networks
Home-page: https://github.com/charlesshang/DCNv2
Author: charlesshang
Author-email: UNKNOWN
License: UNKNOWN
Location: /home/liuhao/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2/liuhao
Requires:
Required-by:
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$ python ./liuhao/setup.py develop running develop running egg_info creating DCNv2.egg-info writing DCNv2.egg-info/PKG-INFO writing dependency_links to DCNv2.egg-info/dependency_links.txt writing top-level names to DCNv2.egg-info/top_level.txt writing manifest file 'DCNv2.egg-info/SOURCES.txt' reading manifest file 'DCNv2.egg-info/SOURCES.txt' writing manifest file 'DCNv2.egg-info/SOURCES.txt' running build_ext building '_ext' extension creating build creating build/lib.linux-x86_64-3.7 g++ -pthread -shared -B /home/liuhao/anaconda3/envs/mydetection_python3.7.3/compiler_compat -L/home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib -Wl,-rpath=/home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib -Wl,--no-as-needed -Wl,--sysroot=/ -L/usr/local/cuda/lib64 -lcudart -o build/lib.linux-x86_64-3.7/_ext.cpython-37m-x86_64-linux-gnu.so copying build/lib.linux-x86_64-3.7/_ext.cpython-37m-x86_64-linux-gnu.so -> Creating /home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib/python3.7/site-packages/DCNv2.egg-link (link to .) Adding DCNv2 0.1 to easy-install.pth file Installed /home/liuhao/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2 Processing dependencies for DCNv2==0.1 Finished processing dependencies for DCNv2==0.1 (mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$
#==========================================================================
#会在/home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib/python3.7/site-packages/生成:
easy-install.pth
DCNv2.egg-link
#会在/home/liuhao/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2/生成:
build文件夹(里面有_ext.cpython-37m-x86_64-linux-gnu.so)
DCNv2.egg-info文件夹
_ext.cpython-37m-x86_64-linux-gnu.so
#这个不在liuhao文件夹里面
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$ pip list
Package Version Location
-------------------- ------------------ -------------------------------------------------------------------------
DCNv2 0.1 /home/liuhao/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$ pip show dcnv2
Name: DCNv2
Version: 0.1
Summary: deformable convolutional networks
Home-page: https://github.com/charlesshang/DCNv2
Author: charlesshang
Author-email: UNKNOWN
License: UNKNOWN
Location: /home/liuhao/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2
Requires:
Required-by:
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2$
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。