我有一個測試設置文件,我爲一個簡單的「hello world」腳本進行了設置。我有一個名爲mytest
的程序包,它具有函數hello
。現在,我有一個非常簡單的setup.py
。一切正常,如果我只是運行python setup.py install
。但是,如果我想要將lib安裝到主文件夾(python setup.py install --home=/home/blah
)中,則該包不再可用(在python中運行import mytest
會給我)。將python setup.py安裝到替代路徑中找不到已安裝的軟件包
我應該手動添加pth文件到site-packages
文件夾嗎?我試了一下(內容爲/home/blah/lib/python
,我的包放在那裏),輸入mytest
工作正常。不應該自動完成嗎?或者我錯過了什麼?
編輯:
的輸出安裝:
[email protected]:~/py/mytest-0.1$ python setup.py install --home=/home/ago/py/ running install running build running build_py copying src/mytest/mytest.py -> build/lib.linux-x86_64-2.6/mytest running build_scripts copying and adjusting src/main.py -> build/scripts-2.6 running install_lib copying build/lib.linux-x86_64-2.6/mytest/mytest.py -> /home/ago/py//lib/python/mytest byte-compiling /home/ago/py//lib/python/mytest/mytest.py to mytest.pyc running install_scripts copying build/scripts-2.6/main.py -> /home/ago/py//bin changing mode of /home/ago/py//bin/main.py to 755 running install_egg_info Removing /home/ago/py//lib/python/mytest-0.1.egg-info Writing /home/ago/py//lib/python/mytest-0.1.egg-info
和setup.py:
from distutils.core import setup setup(name='mytest', description='test', author='Ago', author_email='email', version='0.1', package_dir={'mytest': 'src/mytest'}, packages=['mytest'], scripts=['src/main.py'] )
文件夾結構:
-src: -mytest: __init__.py mytest.py main.py setup.py
main.py
只是一個executabl e輸入mytest並調用函數打印hello world。但我試圖在python中運行import mytest
來查看是否安裝了lib。
那麼,目前我已經將mytest.pth文件添加到`site-packages`內容爲`/ home/ago/py/lib/python`。但是,如果有人有解決方案,爲什麼我的模塊/軟件包不能用`python setup.py install`,我仍然感興趣。謝謝! – Ago 2010-12-11 08:00:19