Reputation: 43
After installing matplotlib. I am getting this error while using this command :
$ import matplotlib
import-im6.q16: attempt to perform an operation not allowed by the security policy `PS` @ error/constitute.c/IsCoderAuthorized/408.
Can anyone help me solve this?
Upvotes: 4
Views: 6945
Reputation: 9295
See the other, older answers. They are very good.
Another possible reason: It might be a cut-and-paste-from-clipboard error.
You may have blanks before your #!/usr/bin/env python3
line, and at the beginning of all following lines. Thus your script is still a valid python-script but the shell cannot interpret the #!/usr/bin/env python3
line. It thus reads your script as a bash script.
It might help to remove the whitespace; or call the script with
python3 myscript.py
Upvotes: 1
Reputation: 392
You are calling import matplotlib
not from the python shell, but from the system shell. The error you are seeing is from the import
command, which according to man import
saves a portion of a screen to an image. This also happens if you execute a script by calling it without putting a shabang on the first line (like #!/usr/bin/env python3
)
Upvotes: 6
Reputation: 166
Depends on how you do import matplotlib
The problem can be solved with just one of the following solutions.
./myfile.py
then it's wrong because you have to write on the command line python myfile.py
or python3 myfile.py
, if you're using Python3#!/bin/python
or #!/usr/bin/python
and then on the command line you can simply run your file like a bash file ./myfile.py
Upvotes: 1
Reputation: 1529
This happens to me if I run import
from the shell. Demonstration:
$ import
import-im6.q16: missing an image filename `import' @ error/import.c/ImportImageCommand/1289.
This askubuntu
question tells me that import
is a built-in ImageMagick command.
You first have to start a Python interactive prompt:
python
>>> import matplotlib
Upvotes: 1