问题标签 [setup.py]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
41241 浏览

python - 将 python setup.py 安装到备用路径中找不到已安装的包

我有一个测试设置文件,我制作了一个简单的“hello world”脚本。我有一个名为的包mytest,它有一个功能hello。现在,我有一个非常简单的setup.py. 一切正常,如果我只是运行python setup.py install. 但是,如果我想将 lib 安装到主文件夹 ( python setup.py install --home=/home/blah) 中,则该软件包不再可用(import mytest在 python 中运行给了我ImportError: No module named mytest)。

我应该手动将 pth 文件添加到site-packages文件夹中吗?我试过了(使用 contents /home/blah/lib/python,我的包放在哪里)并且导入mytest工作正常。不应该自动完成吗?还是我错过了什么?

编辑:

安装输出:

和 setup.py:

文件夹结构:

main.py只是一个可执行文件,它导入 mytest 并调用函数来打印 hello world。但我试图import mytest在 python 中运行以查看是否安装了 lib。

0 投票
2 回答
4102 浏览

python - 如何在 python setup.py 中对文件进行 chmod?

我用 setup.py 创建了一个 python 包安装,我希望它在文件夹中复制一个数据文件(为这个场合创建)~/.did。问题是我必须使用 sudo 权限调用 setup.py,因为它写入 /usr/local/... 所以当我的数据文件复制到 ~/.did 时,只有 root 用户对文件有写访问权限.

然后我决定在 setup() 函数之后添加对 os.chmod() 的调用,但我想知道是否有人有更干净的方法来这样做。

这是我的 setup.py 文件:

由于 did.xml 不是 python 文件,我还创建了一个 MANIFEST.in 文件,其中包含以下行:

我的包的全局结构如下:

0 投票
1 回答
606 浏览

python - 如何创建使用 tar 文件的 setup.py

我们的系统人员将源代码捆绑在 git 中,并且不支持 pip。git 存储库包含一个压缩的 tar 文件。并且 tar 文件中有一个 setup.py 。我认为在我的项目中公开它的最简单方法是在-e git...我的 pip requirements.txt 中添加一行,并在 git 存储库的根目录中添加一个 setup.py 以供 pip 使用。最后一步是如何编写一个 setup.py 来安装一个 tar 文件作为源分发。


或者,我可以得到一个 setup.py 来做这些事情:

0 投票
1 回答
710 浏览

python - buildout MercurialRecipe 在多次导入时中断

我一直在尝试导入几个实际上依赖于我正在构建的鸡蛋的包。因为这些鸡蛋不在奶酪店里,所以我无法nstall_requires = ['pack1', 'pack2']在我的setup.py脚本中使用 i,所以我尝试通过以下方式将它们添加到我的构建配置中:

我可能以错误的方式做这件事——我只是从构建开始。当我运行我的 bin/buildout 时,出现以下错误:

如果我切换 pack1 和 pack2,则安装 pack2。基本上它们都可以正常工作,但是一旦我尝试获取它们两个-它就会破坏一切。

提前致谢。马丁

0 投票
1 回答
3950 浏览

python - “来自 distutils.core 导入设置”的 Python 帮助

我在 python setup.py 文件中经常看到这种代码。

它到底是什么意思?它是如何工作的?我试图理解代码。ps:对不起我英语不好的xP

0 投票
4 回答
7603 浏览

python - 在 setup.py 或 pip 需求文件中,如何控制安装包依赖项的顺序?

我有一个 Python 包,它的 setup.py 具有通过通常方式在 install_requires=[...] 中声明的依赖项。那里的一个包 scikits.timeseries 有一个 setup.py 期望已经安装了 numpy,因此,我想要一些方法来首先安装 numpy。对于这种情况和一般情况,可以控制依赖安装的顺序吗?如何?

目前,setup.py 拉下依赖项的顺序(如 arg install_requires 中列出的)看起来几乎是随机的。另外,在 setup.py setup(...) 我尝试使用 arg:

...没有成功,安装依赖项的顺序不受影响。

我也尝试设置一个 pip 需求文件,但是 pip 安装依赖项的顺序与需求文件的行顺序不匹配,所以没有运气。

另一种可能性是在 setup.py 顶部附近有一个系统调用,在 setup(...) 调用之前安装 numpy,但我希望有更好的方法。提前感谢您的帮助。

0 投票
1 回答
942 浏览

python - want to use distutils to install my python app with a "one-click" launcher file

I'm trying to figure out how to make my program installable via distutils. My end goal is to make a .deb installer for ubuntu users. The main issue is getting a "one-click" launcher file to work.

My program uses pygtk and sqlite3 for the gui and database. I've used glade to help build my gui and so my program ties into a couple of glade files. and then I also store data in a .sqlite3 file. Here is my package structure so far...

this is my current setup.py file...

the code for my "recipetrack" script is...

So the recipetrack get's installed outside of the root directory and has it's permissions changed to 755, so that all users on the system can launch the file. Once started recipetrack should start module which is in the root folder and then starts the main.py from there everything should run as normal. But it doesn't. "recipetrack" does start module which then imports main.py class but it's at this point the program tries to load data files (ie. data.sqlite3, main.glad, or addRecipe.glad.) and then just hangs unable to locate them.

If I cd into the root of the program and run "recipetrack" the program runs normally. But I want to be able to run "recipetrack" from any location on the system.

I believe the problem lies in the setup.py file with the package_data line. I have tried using data_files instead but this doesn't work it hangs during install unable to locate the data files.

I hope this has been clear, and someone out there can help.

Thanks, Heber

changed setup.py file...

But now setup isn't installing my data.sqlite3 file.

0 投票
5 回答
16178 浏览

python - pip install PyQt IOError

我正在尝试使用 pip 安装 PyQt 包,但出现此错误:

0 投票
1 回答
348 浏览

dependencies - imdbpy 和 setuptools - 依赖问题

目前我正在处理我的第一个python项目,如果有些问题似乎有点太简单了,请提前抱歉......无论如何。

我的简单项目使用 imdbpy - Python 包来访问 IMDb 的数据库(http://pypi.python.org/pypi/IMDbPY/)。imdbpy 尤其依赖于 lxml。

当我尝试使用 python setup.py 脚本安装我的项目时出现问题。

安装过程中产生的错误信息:

** 确保已安装 libxml2 和 libxslt 的开发包 **

使用 libxslt 的构建配置

所以我需要 libxml2 和 libxslt 但无法通过 pypi 访问。

我在 Stackoverflow 上发现了类似的问题:python setuptool 如何为 libxml2-dev 和 libxslt1-dev 添加依赖项?但答案并不能解决我的问题。

这种依赖问题有什么解决方法吗?

我可以补充一点,如果 libxml2-dev 和 libxslt1 安装有:

sudo apt-get install libxml2-dev sudo apt-get install libxslt1-dev

然后我的安装脚本成功进行。

提前感谢您的任何想法。

0 投票
1 回答
125 浏览

python - 帮助 MySQLdb 模块:损坏的安装和连接到远程服务器

我是 Python 新手,在启动和运行 MySQLdb 时遇到了一些基本问题。我希望有人可以帮助我。

当我第一次尝试使用 setup.py 安装模块时,安装程​​序终止,因为它无法找到 mysql_config。这是因为我没有意识到要在本地机器上安装 MySQL 的模块。我只是想连接到远程 MySQL 服务器。

我的问题是双重的:

1)我应该如何在没有安装 MySQL 的机器上使用 MySQLdb,只连接到远程服务器?

2) 如何回滚似乎损坏的 MySQLdb 安装?每当我尝试从脚本导入 MySQLdb 时,我都会收到错误“没有名为 _mysql 的模块”,根据文档,这表明安装错误。

顺便说一句:我在运行 Snow Leopard/Python 2.6.1 的 Mac 上

谢谢!