plt.style.use('./deeplearning.mplstyle') is not working - matplotlib

I am trying to run the optional labs of the machine learning specialization from coursera, and I stuck with some libraries and functions that
I can not install
plt.style.use('./deeplearning.mplstyle')
I got the error message
ModuleNotFoundError Traceback (most recent call last)
in
3 import matplotlib.pyplot as plt
4 print(plt.style.available)
----> 5 plt.style.use('./deeplearning.mplstyle')
OSError: './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
What can I do?

It is because you may did not download all the files from coursera. Make sure to download all the files, especially, deeplearning.mplstyle, lab_utils_common.py, lab_utils_multi.py and keep them in one folder.

You need to download the deeplearning.mplstyle file to use the plotting style.
To download this file from the Optional Lab follow these steps
Open the Optional Lab from your course.
Click on File -> Open
Select deeplearning.mplstyle and select download option on top
Save this file to your working directory. To use plt.style.use('./deeplearning.mplstyle') as is - make sure your main code file and deeplearning.mplstyle are in the same folder.

Related

Custom Block Unable to Be Found

I have an Ubuntu LTS20.04 vm with with GNU Radio installed via PPA. Following the Guided Tutorial GNU Radio in C++, I've created, built, and installed a project identical to the sample presented within.
I went to set up the objective flow graph presented at the beginning of the tutorial in GNURadio companion, but when I attempt to execute the it, I get the following error:
Warning: failed to XInitThreads()
Traceback (most recent call last):
File "/home/user/Documents/GNURadio Flowgraphs/testqpsk.py", line 38, in <module>
import tutorial
ModuleNotFoundError: No module named 'tutorial'
What steps do I need to take to resolve this? I should note that the PPA install does not seem to configure paths correctly, as I had to EXPORT GR_PREFIX=/usr to get gr_modtool to function.
The problem was that cmake's default install prefix (/usr/local) does not correspond with default Python search paths. My resolution was the following:
export PYTHONPATH=/usr/local/lib/python3/dist-packages:/usr/lib/python3/dist-packages:$PYTHONPATH
Both this export statement and the GR_PREFIX export were added to my ~/.profile.

Running pyiron under Windows leads to error about .pyiron configuration

I installed pyiron according to the instructions under Windows via conda. Everything worked without any errors. Then, I started a new notebook, and ran the commands:
from pyiron import Project
where I got the message:
Fall back to default configuration: {'resource_paths': ['~/pyiron/resources'], 'project_paths': ['~/pyiron/projects']}
and then, I tried to start a new project via:
pr = Project('test')
Here, errors occurred such as:
ValueError Traceback (most recent call last)
<ipython-input-2-f4cd01081291> in <module>
----> 1 pr = Project('test')
C:\Anaconda3\lib\site-packages\pyiron\project.py in __init__(self, path, user, sql_query)
108
109 def __init__(self, path="", user=None, sql_query=None):
--> 110 super(Project, self).__init__(path=path, user=user, sql_query=sql_query)
111 self.job_type = JobTypeChoice()
112 self.object_type = ObjectTypeChoice()
and finally, the message:
ValueError: the current path C:/Users/nau/pyiron/test/ is not included in the .pyiron configuration. ['C:/Users/nau/pyiron/projects/']
(nau is my user name). Do I have to initialize a file .pyiron in a certain folder first? If yes, how? The folder C:/Users/nau/pyiron/projects/ didn't exist.
This is a bug and should be fixed in the code - I am going to create a separate issue on Github shortly.
In the mean time you can fix it on your system, by either creating the folder manually:
C:/Users/nau/pyiron/projects/
And then execute the jupyter notebook in this folder.
Or you can create the pyiron configuration files by executing the following commands:
import pyiron
pyiron.install()
This is going to ask you:
It appears that pyiron is not yet configured, do you want to create a default start configuration (recommended: yes). [yes/no]:
And then you can confirm with yes which is going to create a C:/Users/nau/.pyiron file with the configuration. This file you can then update manually. By changing the line:
PROJECT_PATHS = C:/Users/nau/pyiron/projects/
to:
PROJECT_PATHS = C:/Users/nau/pyiron/
I hope this solves your issue.
Ps: Can you tell me which version of pyiron you are using? You can identify the version using conda list pyiron.

Import does not function as bat file; but works in spyder

I am still not the most sophisticated python user; but I cannot overcome this probably simple problem. I have a code that works perfectly with the spyder interface. I would like to make it a recurring task via creating a bat file. The bat file which in turn triggers a cmd interface does not import pandas_data reader and the code gets stuck and aborts.
import pandas_datareader.data as web
this line above creates the error below. It's a lengthy text.
File "C:\Users\myself\anaconda3\lib\site-packages\pandas_datareader\__init__.py", line 2, in <module>
from .data import ( File "C:\Users\myself\anaconda3\lib\site-packages\pandas_datareader\data.py", line 9, in <module>
from pandas.util._decorators import deprecate_kwarg File "C:\Users\myself\anaconda3\lib\site-packages\pandas\__init__.py", line 17, in <module>
"Unable to import required dependencies:\n" + "\n".join(missing_dependencies) ImportError: Unable to import required dependencies: numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
1. Check that you expected to use Python3.7 from "C:\Users\myself\anaconda3\python.exe",
and that you have no directories in your PATH or PYTHONPATH that can
interfere with the Python and numpy version "1.17.0" you're trying to use.
2. If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
- If you're working with a numpy git repository, try `git clean -xdf`
(removes all files not under version control) and rebuild numpy.
Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.
Original error was: DLL load failed: The specified module could not be found.

Running numpy from Pycharm

I am unable to run numpy in Pycharm BUT works fine in the Terminal. How do I make numpy work in Pycharm?
This is the error message I get in Pycharm
Traceback (most recent call last):
File "/Users/giridhar/PycharmProjects/numpy/testfile", line 12, in <module>
a = np.array([1, 2, 3]) # Create a rank 1 array
AttributeError: module 'numpy' has no attribute 'array'
Update:
It's quite likely that you have a file called numpy.py in another directory.
When you run testfile.py in your terminal, you are inside of your directory 'numpy' which does not have a file numpy.py and that's why it finds the correct numpy-module.
However, in PyCharm you can add directories to Sources Root (i.e. sys.path as explained in this answer) which apparently contains a file called numpy.py. Remove that directory from your sys.path (as explained by jetbrains) and it should also work in PyCharm.
Old answer (wrong!):
As of my knowledge, the directory name does not interfere with module names unless maybe you define your directory as a package using __init__.py
You need to be careful with how you name your directories. It's possible that the Python interpreter uses your directory 'numpy' to find the function 'array()' instead of using the PyPI numpy-module. Re-naming that directory might fix your issue.
So, e.g. "/Users/giridhar/PycharmProjects/my-numpy/testfile"

Error with PyQtDeploy

I'm using PyQt 5.3.1 and I'm deploying with pyqtdeploy 0.4 and when i want to build a project i obtain this error message:
Generating code...
Cleaning E:\ProgramasPython3\PythonQT\QTCalculator\build.
Freezing C:\Users\Tobal\AppData\Local\Temp\bootstrap_py3.py
Freezing E:\ProgramasPython3\PythonQT\QTCalculator\qtcalculator.py
Freezing E:/ProgramasPython3/PythonQT\QTCalculator\__init__.py
Freezing E:/ProgramasPython3/PythonQT\QTCalculator\calculator_ui.py
Freezing E:/ProgramasPython3/PythonQT\QTCalculator\img_rc.py
Freezing E:/ProgramasPython3/PythonQT\QTCalculator\qtcalculator.py
Freezing C:\Python34\libs\site-packages\PyQt5\__init__.py
Unable to freeze C:\Python34\libs\site-packages\PyQt5\__init__.py.
Traceback (most recent call last):
File "C:\Users\Tobal\AppData\Local\Temp\freeze.py", line 103, in <module>
freeze_as_data(py_file, options.as_data)
File "C:\Users\Tobal\AppData\Local\Temp\freeze.py", line 36, in freeze_as_data
code = _get_marshalled_code(py_filename)
File "C:\Users\Tobal\AppData\Local\Temp\freeze.py", line 71, in _get_marshalled_code
source_file = open(py_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Python34\\libs\\site-packages\\PyQt5\\__init__.py'
I think this is a bug. someone does know how to fix it?
Thanks
Did you build PyQt5 statically? The host and target Python are two different things, and often in different directories. The target Python has PyQt module built statically, the host Python must also have PyQt5 installed (because pyqtdeploy uses Qt for its GUI) but its usually a dynamic library in the host Python.
In the pyqtdeploy GUI on "Locations" tab, make sure that "Standard library directory" is correct.