gpt4 book ai didi

python-3.x - 如何直接将python模块安装到dist-packages目录中?

转载 作者:行者123 更新时间:2023-12-02 03:51:31 29 4
gpt4 key购买 nike

我在/tmp 中构建了一个包。

tree myanalyse
myanalyse
├── myanalyse
│ ├── ana.py
│ ├── __init__.py
├── README.md
└── setup.py

本地安装。

cd  /tmp/myanalyse
sudo python3 setup.py build
sudo python3 setup.py install

现在检查一下。

import  myanalyse
print(myanalyse.__path__)
['/usr/local/lib/python3.5/dist-packages/myanalyse-0.1-py3.5.egg/myanalyse']

通常情况下,当你在Python中安装pandas这样的模块时,/usr/local/lib/python3中必须有一个目录pandas。 5/dist-packages.

import pandas
print(pandas.__path__)
['/usr/local/lib/python3.5/dist-packages/pandas']

它是 /usr/local/lib/python3.5/dist-packages/myanalysis-0.1-py3.5.egg/myanalysis ,而不是 /usr/local/lib/python3.5/dist-packages/myanalysis 在我的 python 中,如何以 /usr/local/lib/python3.5/dist- 格式安装此包 myanalysis packages/myanalysis ,而不是 /usr/local/lib/python3.5/dist-packages/myanalysis-0.1-py3.5.egg/myanalysis

最佳答案

您可以使用:

python3 setup.py install --single-version-externally-managed --root=/

或者您也可以使用以下命令强制进行非鸡蛋构建:

python3 setup.py install --old-and-unmanageable

来自docs :

Note When installing packages as egg, data_files is not supported. So, if your project uses setuptools, you must use pip to install it. Alternatively, if you must use python setup.py, then you need to pass the --old-and-unmanageable option.

关于python-3.x - 如何直接将python模块安装到dist-packages目录中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60312825/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com