python3 setup.py安装失败(RHEL 8)

时间:2020-01-09 05:14:21

标签: python python-3.x python-3.6 setuptools distutils

问题:

#python3 setup.py install

失败

环境:RHEL 8 UBI容器


我有一个看起来像这样的setup.py :(对此setup.py的任何指针或更新都会感激)

import setuptools

print('python/setup.py')

setuptools.setup(
      name="process_data",
      version="1.0",
      description="desc",
      author="FirstName LastName",
      author_email="dude@abides.abide",
      url="https://some.com",
      packages=setuptools.find_packages(),
)

我具有这样的目录结构(每个目录中的<some>.py以及__init__.py):

python/
 setup.py
 <dir>/__init__.py
 <dir>/__init__.py
 <dir4>/__init__.py
 <dir4>/<sub-dir1>/__init__.py
 <dir4>/<sub-dir1>/<sub-dir>__init__.py

我希望每个目录中的代码都成为模块包的一部分,以便我可以导入,嵌套,无论深度如何。


我正在这样做:

#cd python
#python3 setup.py install

我收到此错误:

python/setup.py
running install
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

/usr/local/lib/python3.6/site-packages/test-easy-install-1625.write-test

    [Errno 2] No such file or directory: '/usr/local/lib/python3.6/site-packages/test-easy-install-1625.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /usr/local/lib/python3.6/site-packages/

This directory does not currently exist.  Please create it and try again, or
choose a different installation directory (using the -d or --install-dir
option).

问题:

这是哪里来的? test-easy-install-1625.write-test? (对这是什么感到困惑)

在我的系统上,实际上这个目录确实不存在(为什么 python3 setup.py install在那儿看?告诉它在那儿看什么?): /usr/local/lib/python3.6

我的setup.py中没有任何东西可以指示要去那里。


我四处张望,看起来像/ site-packages /目录在这里(运行pip时安装了其他模块)

`/usr/local/lib64/python3.6/site-packages/`

我该如何解决?

谢谢,我非常需要立即解决此问题。我一直在Windows上工作,>python setup.py install只是在那里工作。

我应该设置任何环境变量吗?

我只是用dnf -y install python36安装了python就是这样。 (最新的版本可以在任何RHEL 8软件包存储库中进行安装)。

3 个答案:

答案 0 :(得分:2)

我遇到了同样的错误,并且可以通过创建符号链接来修复它。我接受其他人也许能够提供更优雅的解决方案,我对此表示欢迎。

sudo mkdir /usr/local/lib/python3.6
sudo ln -s /usr/lib/python3.6/site-packages /usr/local/lib/python3.6/

答案 1 :(得分:0)

我假设您已经进入python命令模式,如果没有,则需要以下命令,请注意设置变量Path和PythonPath:

setlocal
set env_name=python3.6
set Path=C:\Users\s41167\Miniconda3\envs\%env_name%;C:\Users\s41167\Miniconda3\envs\%env_name%\Scripts;%Path%
set PythonPath=C:\Users\s41167\Miniconda3\envs\%env_name%\Lib\site-packages
cd C:\Users\s41167\Documents\%env_name%
cmd.exe /K activate %env_name%

如果进入python命令模式,则可以使用pip安装软件包:

pip install <package location> --target <install location> --upgrade

以下是我的安装命令和结果:

(python3.6) C:\Users\s41167\Documents\python3.6>pip install ./python_package --t
arget ./target --upgrade
Processing c:\users\s41167\documents\python3.6\python_package
Building wheels for collected packages: process-data
  Building wheel for process-data (setup.py) ... done
  Created wheel for process-data: filename=process_data-1.0-cp36-none-any.whl si
ze=1721 sha256=ef5eaf061000f30d472e5dde268694733e40a3f8a4a29fa78faec69f125443c9
  Stored in directory: C:\Users\s41167\AppData\Local\Temp\pip-ephem-wheel-cache-
v6lt_ndp\wheels\61\01\f5\07e0760baa10d63e1c43b37eadbb55b79828f4fe337209026a
Successfully built process-data
Installing collected packages: process-data
Successfully installed process-data-1.0

(python3.6) C:\Users\s41167\Documents\python3.6>

和文件排列:

.\python_package
  __init__.py
  setup.py
                \directory
                 __init__.py
                \directory4
                 __init__.py
                            \sub_dirctory1
                             __init__.py

答案 2 :(得分:0)

在 Linux 中使用

sudo python3 setup.py install

在windows中使用

    python setup.py install

python3 setup.py install