没有root的Python setup.py

时间:2018-10-24 11:20:49

标签: python matlab setup.py

我想安装一些Python模块,即MATLAB Engine。 MATLAB全局安装在/usr/local/sw/matlab下,因此我转到相应的目录,然后按链接文档中的说明运行setup.py。但是,我不是root用户,因此我添加了--user标志,如官方Python Docs所述。

这就是我得到的:

> python setup.py install --user running install running build running build_py creating build error: could not create 'build': Permission denied

显然,它尝试在当前目录中构建模块,而我没有写访问权限。我可以通过运行来回避

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...下某个地方的某些源代码?

1 个答案:

答案 0 :(得分:1)

You can use Virtualenv or venv to deal with this kind of issues.

Edit: As we went a bit deeper into issue itself, we managed to figure out the answer.

If you wish to use virtual environment: python setup.py build --build-base="/path/to/directory_you_can_write_to" install --prefix="/path/to/virtualenv/" --user

If you wish to accomplish what @Feodoran asked for: python setup.py build --build-base="/path/to/directory_you_can_write_to" install --user

Useful links: