I would like to install some Python module, namely the 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 .
So this is what I get:
> python setup.py install --user running install running build running build_py creating build error: could not create 'build': Permission denied
Apparently it tries to build the module in the current directory, where I have no write access. I can sidestep this by running
python setup.py build --build-base=/path/to/temp/build/dir
But then I don't know how to install that. Also I cannot combine those 2 approaches as install
does not recognize the --build-base
option.
I furthermore tried to copy the whole matlabroot/extern/engines/python
directory somewhere else and run python setup.py install --user
there, but this yields
error: The installation of MATLAB is corrupted. Please reinstall MATLAB or contact Technical Support for assistance.
I guess it does not find the matlabroot
anymore.
So how do I build and install some source located somewhere under /usr...
without being root?
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:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.