0

I'm going to try machine learing lab which is conducted by Prof.Andrew Ng in my pycharm.
but if I run one of it and found that it just run as follows:

import math,copy
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('./deeplearning.mplstyle')

but if I attach this to the end

from lab_utils_uni import plt_house_x, plt_contour_wgrad, plt_divergence, plt_gradients

it shows the error

`Traceback (most recent call last):
  File "D:\pythonProject1\venv\lib\site-packages\matplotlib\style\core.py", line 115, in use
    rc = rc_params_from_file(style, use_default_template=False)
  File "D:\pythonProject1\venv\lib\site-packages\matplotlib\__init__.py", line 798, in rc_params_from_file
    config_from_file = _rc_params_in_file(fname, fail_on_error=fail_on_error)
  File "D:\pythonProject1\venv\lib\site-packages\matplotlib\__init__.py", line 727, in _rc_params_in_file
    with _open_file_or_url(fname) as fd:
  File "C:\Users\MIR-PC\AppData\Local\Programs\Python\Python38\lib\contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "D:\pythonProject1\venv\lib\site-packages\matplotlib\__init__.py", line 705, in _open_file_or_url
    with open(fname, encoding=encoding) as f:
FileNotFoundError: [Errno 2] No such file or directory: 'linear_regression/deeplearning.mplstyle'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\pythonProject1\ml\linear_regression\linear_regression_Gradient_descent.py", line 7, in <module>
    from lab_utils_uni import plt_house_x, plt_contour_wgrad, plt_divergence, plt_gradients
  File "D:\pythonProject1\ml\linear_regression\lab_utils_uni.py", line 11, in <module>
    from lab_utils_common import compute_cost
  File "D:\pythonProject1\ml\linear_regression\lab_utils_common.py", line 9, in <module>
    plt.style.use('linear_regression/deeplearning.mplstyle')
  File "D:\pythonProject1\venv\lib\site-packages\matplotlib\style\core.py", line 118, in use
    raise IOError(
OSError: 'linear_regression/deeplearning.mplstyle' not found in the style library and input is not a valid URL or path; see `style.available` for list of available styles

In addition the D:\pythonProject1\venv is my workspace.
I promise that util.py and mplstyle are in the directory.
It takes me about 3h and I still can't find solution. enter image description here enter image description here

And I had tried to attach the mplstyle to the path "D:\pythonProject1\venv\lib\site-packages\matplotlib\style".
It also can't effect.

desertnaut
  • 57,590
  • 26
  • 140
  • 166
bf k
  • 1

1 Answers1

1

Try this

plt.style.use('file:c://YOUR_ABSOLUTE_FILE_PATH/deeplearning.style')

BTW, my code editor is VS Code.