Python setup.py 无根
Python setup.py without root
我想安装一些 Python 模块,即 MATLAB Engine. MATLAB is installed globally under /usr/local/sw/matlab
, so I change to the corresponding directory and then run setup.py
as explained in the linked documentation. However, I am not root, so I added the --user
flag, as documented by the official Python Docs.
这就是我得到的:
> python setup.py install --user
running install
running build
running build_py
creating build
error: could not create 'build': Permission denied
显然它试图在我没有写权限的当前目录中构建模块。我可以通过 运行ning
来回避这个问题
python setup.py build --build-base=/path/to/temp/build/dir
但是我不知道如何安装它。此外,我无法将这两种方法结合起来,因为 install
无法识别 --build-base
选项。
我还试图将整个 matlabroot/extern/engines/python
目录复制到其他地方,然后将 运行 python setup.py install --user
复制到那里,但这会产生
error: The installation of MATLAB is corrupted. Please reinstall MATLAB or contact Technical Support for assistance.
我猜它再也找不到 matlabroot
。
那么如何在不使用 root 的情况下构建和安装位于 /usr...
下某处的源代码?
您可以使用Virtualenv or venv来处理此类问题。
编辑:随着我们更深入地研究问题本身,我们设法找到了答案。
如果你想使用虚拟环境:python setup.py build --build-base="/path/to/directory_you_can_write_to" install --prefix="/path/to/virtualenv/" --user
如果你想完成@Feodoran 的要求:python setup.py build --build-base="/path/to/directory_you_can_write_to" install --user
有用的链接:
我想安装一些 Python 模块,即 MATLAB Engine. MATLAB is installed globally under /usr/local/sw/matlab
, so I change to the corresponding directory and then run setup.py
as explained in the linked documentation. However, I am not root, so I added the --user
flag, as documented by the official Python Docs.
这就是我得到的:
> python setup.py install --user
running install
running build
running build_py
creating build
error: could not create 'build': Permission denied
显然它试图在我没有写权限的当前目录中构建模块。我可以通过 运行ning
来回避这个问题python setup.py build --build-base=/path/to/temp/build/dir
但是我不知道如何安装它。此外,我无法将这两种方法结合起来,因为 install
无法识别 --build-base
选项。
我还试图将整个 matlabroot/extern/engines/python
目录复制到其他地方,然后将 运行 python setup.py install --user
复制到那里,但这会产生
error: The installation of MATLAB is corrupted. Please reinstall MATLAB or contact Technical Support for assistance.
我猜它再也找不到 matlabroot
。
那么如何在不使用 root 的情况下构建和安装位于 /usr...
下某处的源代码?
您可以使用Virtualenv or venv来处理此类问题。
编辑:随着我们更深入地研究问题本身,我们设法找到了答案。
如果你想使用虚拟环境:python setup.py build --build-base="/path/to/directory_you_can_write_to" install --prefix="/path/to/virtualenv/" --user
如果你想完成@Feodoran 的要求:python setup.py build --build-base="/path/to/directory_you_can_write_to" install --user
有用的链接: