How to install matlabengine (Windows 10, MATLAB R2020b, Python 3.8.10) - python

I have the following environment:
Windows 10
Python 3.8.10
MATLAB R2020b
I'm trying to install matlabengine (pip install matlabengine) package, and I'm getting the following error:
RuntimeError: No compatible MATLAB installation found in Windows Registry. This release of MATLAB Engine API for Python is compatible with version 9.13. The found versions were 9.9
What am I missing ? (according to https://pypi.org/project/matlabengine/) it seems I'm using the right versions.
How can I check the versions I have (9.9 or 9.13 because as I wrote above I have MATLAB R2020b and Python 3.8.10).

The error is about the MATLAB version, not the version of matlabengine (the Python module).
You wrote that you have MATLAB 2020b. That is the release name for MATLAB version 9.9, as can be seen in this table on Wikipedia.
As can be read on the description of matlabengine 9.13.1, this engine version requires MATLAB release R2022b (= 9.13).
To use matlabengine with MATLAB 2020b, install version 9.9.1:
python -m pip install matlabengine==9.9.1

You need to try all versions of MATLAB engine starting from the latest one going backwards. What worked for me on Ubuntu was
$ python -m pip install matlabengine==9.12.17
NB: To get a list of all the possible versions, try install one that doesn't exist e.g.
$ python -m pip install matlabengine==9.9.2
and it will give you an error with the list of possible versions.

You can try to install specific version of matlabengine.
pip install matlabengine==9.13.1
If they cannot find your version, you might need to update pip.
Also, you can check your current matlabengine version.
pip show matlabengine

Related

Cannot pip-install earlier version (1.15) of TensorFlow, even in Python 3.6

I am trying to install and use a package called FinRL. This package has a dependency, StableBaselines which uses tensorflow. It says in FinRL documentation that FinRL only works with TensorFlow 1.x , so I need to install earlier versions of tensorflow (in their examples, they use tensorflow==1.15.4 ).
I tried doing it in Python 3.9, but I got the error "No matching distribution found for tensorflow==1.15.4" . After some reading through threads like this one , I downloaded Python 3.6.4 to try again. Once again, when I run "pip install tensorflow=1.15.4" in Python 3.6.4 (I ran "python --version" in command prompt, after navigating to the Python folder to make sure I was using Python 3.6.4 ) .
As the thread suggested, I also made sure I was using an upgraded pip, so I upgraded it. Currently using pip 22.1 . However, I notice that it says "pip 22.1 from C:.......Python3.9... Could this be the issue? I do have both, Python 3.6.4 and Python 3.9 installed on my computer.
Do you have any advice or suggestions for how I can get this package or early TensorFlow installed/working?
Thank you!

Getting an error saying "Could not build wheels for numpy which use PEP 517 and cannot be installed directly" while installing numpy

I am trying to install a specific version of numpy using the command pip install numpy=1.19.1 in a python virtual environment. But I am getting the following errors
ERROR: Failed building wheel for numpy
Failed to build numpy
ERROR: Could not build wheels for numpy which use PEP 517 and cannot be installed directly
How do I solve this? I am using Python 3.9.6 and Pip 21.1.3. And I am on macOS Big Sur.
I was facing the same error on my MacBook Air(macOS BigSur) Laptop while installing the Numpy package via integrated terminal of VS Code. And I found the solution:
So previously I was using older version of pip i.e. 19.2.3.
But when I upgraded it to the latest version using command
pip install --upgrade pip
and after that when running the command
pip install numpy
it worked absolutely fine.
At the time running the above commands, my python version was 3.8.2.
I think NumPy is not yet being prepared for Python 3.9 since they need to check a lot of times. You should try Python 3.7 or 3.8 is better.
See this thread: https://github.com/numpy/numpy/issues/17569
Edit: Based on the latest news on numpy's website (dated 31st December) Numpy appears to now be supporting python 3.9 and 3.10 as well
If you're on Windows, then install Visual Studio 2019 Build Tools, then go to 'Individual components', then tick the latest version of 'Windows 10 SDK', and 'MSVC v142 x64/86 build tools - Latest'. That solved this error for me, except for me this error came when installing discord.py.
Try seeing if it works with Python 3.8 first though, just like Dhananjay's answer. That could save you a lot of storage, because Visual Studio takes up lots of space. If that doesn't work, you can try my answer.
Edit: I just realised, you said you're on Mac. Try this:
type python -VV in terminal
It should say something like this:
Python 3.9.6 (default, Jun 29 2021, 10:19:25)
[GCC 10.3.0]
Whatever it says on the second line is what you will need to install. I use Python on Ubuntu 21.10 on WSL2, which uses GCC 10.3.0, and I have GCC 10.3.0 installed.
Similarly to the answers above, switching to Python 3.8 solved the issue. Additionally, because of this issue, I couldn't install scikit-image which depends on numpy.
I created a virtual environment of Python 3.8 using conda i.e. conda create -n py38 python=3.8 to switch python version. I have Mac M1, 2020 updated to OS Monterey, version 12.0.1.
yea, I was also using python 3.10 and switched back to python 3.8.
check this link python/downloads to download python 3.8

ERROR: (wheel).whl is not a supported wheel on this platform

I'm trying to build Tensorflow from source (if I install directly it works fine but I'm trying to get AVX2/FMA extensions support as I can't use CUDA/GPU) and I'm following this tutorial to build Tensorflow 1.15 (which is needed for the project that I use, I can't use 2.x).
I've built Tensorflow successfully, but when I try to install the wheel with pip I get the following error:
ERROR: tensorflow-1.15.5-cp37-cp37m-macosx_11_0_x86_64.whl is not a supported wheel on this platform.
Well, I know what the error means but the problem is that:
The wheel, as implied by the filename, is built for:
Python 3.7
macOS 11.0
x86/64
Which is already what I have (yup, double checked Python version, it's exactly Python 3.7.9, and no I'm not on M1 if that matters, I'm on Intel Mac). Why am I getting this error message even though I'm on the platform that the wheel is built for?
UPDATE: I'm already on the latest pip as of writing, and I can verify pip and python point to the same version:
(tf) can#can-mbp tensorflow % which pip
/opt/anaconda3/envs/tf/bin/pip
(tf) can#can-mbp tensorflow % which python
/opt/anaconda3/envs/tf/bin/python
(tf) can#can-mbp tensorflow % pip -V
pip 21.0 from /opt/anaconda3/envs/tf/lib/python3.7/site-packages/pip (python 3.7)
(tf) can#can-mbp tensorflow % python -V
Python 3.7.9
FOR MACOS - BIG SUR
I was able to solve this problem when I found that the version of the macOS operating system does not match the version actually recognized by python
I'm using macOS 11.4, the file is with this version. But when typing a command in the terminal, I found that python recognizes 11.0.
python3
from distutils import util
util.get_platform()
>> 'macosx-11.0-arm64'
generated file name:
opencv_python-4.5.2+2344814-cp39-cp39-macosx_11_4_arm64.whl
new file name:
opencv_python-4.5.2+2344814-cp39-cp39-macosx_11_0_arm64.whl
Upon #Axe319's comment I took a look at https://github.com/apple/tensorflow_macos/issues/46 and seen that simply changing the wheel's filename's OS section to 10_9 works. There is probably a bug with parsing macOS 11.0 or Python doesn't think it supports 11.0 (maybe that particular Python/pip version was before Big Sur was released).
Make sure the Python version you are using (32/64 bit) does match what the wheel requires ;)

pytest requires Python '>=3.5' but the running Python is 2.7.10

I'm trying to install pytest using pip but running into this error:
pytest requires Python '>=3.5' but the running Python is 2.7.10
Pretty sure pytest is compatible with python 2. Any reason why I am not able to install it on my machine? As you can see in the error, I am running python 2.7.10 and do not have issue installing other packages.
Quoting the changelog:
The 4.6.X series will be the last series to support Python 2 and Python 3.4.
Therefore, use
$ pip install "pytest<5"
to install the latest pytest version that supports Python 2.7.
Here's a fix that works for me:
pip install 'tornado<=5.1'
Taken from the pytest website.
"The pytest 4.6 series will be the last to support Python 2.7 and 3.4, and is scheduled to be released by mid-2019. pytest 5.0 and onwards will support only Python 3.5+."
It's likely that a recent update to pytest now no longer supports your version of Python.
To install pytest 4.6 use the command:
pip install pytest==4.6
Python 2 will be phased out by 2020. Several big packages (like NumPy and matplotlib) have already declared that they are no longer supporting Python 2. Several other packages, like this one, are following suit.
If you want to use this package, I would recommend switching to Python 3. There are already several tools, like 2to3 and six, to support this.

Install Matlab Engine for Python 3.4.5

I need to install the Matlab engine for Python 3.4.5 in an Anaconda environment.
When I try to install the Matlab engine with the following command:
sudo python setup.py install --prefix="/home/<<my user>>/anaconda3"
It creates another folder named python2.7 and inside it creates all the necessary files and folders:
/home/<<my user>>/anaconda3/lib/python2.7/site-packages
When I run which command and the python one they return
which python
/home/<<my user>>/anaconda3/bin/python
python
Python 3.4.5 |Anaconda 4.3.0 (64-bit)
So the system points towards the correct Python version
I even check what version the setup.py finds and it is 3.4
What do I miss?
Cheers,
Dan
I don't know what exactly the issue is, can you import the matlab engine?
If it doesn't work most likely the problem is when you install the engine on a different python environment (in this case the one from Anaconda), you need to link the library from this environment.
On linux you can do:
export LD_LIBRARY_PATH="/home/<<my user>>/anaconda3/lib:$LD_LIBRARY_PATH"
On Mac:
export DYLD_LIBRARY_PATH="/home/<<my user>>/anaconda3/lib:$DYLD_LIBRARY_PATH"
That should work, otherwise you can follow this link.

Categories