9

In ex49, we are told to call the the lexicon.py file created in ex48 with the following command.

When I try to import the lexicon file with the following command

    >>> from ex48 import lexicon

it returns the following:

    from: can't read /var/mail/ex48

I've tried looking this up. What does this mean? Is a file in the wrong place?

chacha
  • 111
  • 1
  • 1
  • 5

3 Answers3

24

You need to add the shebang to the first line of your program. Put in #!/usr/bin/python or where ever your python bin is located and your program will run.

Joe
  • 259
  • 2
  • 2
11

You didn't type "from ex48 import lexicon" in the Python shell, you typed it in at the command line. "from" is the command to list who mail is from, hence the /var/mail location.

You can tell this from the different error messages the commands produce:

localhost-2:~ $ from ex48 import lexicon
from: can't read /var/mail/ex48
localhost-2:~ $ python
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ex48 import lexicon
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named ex48
DSM
  • 342,061
  • 65
  • 592
  • 494
  • So are you saying that I type it into the lexicon.py file? How do I run my lexicon game scanner (ex49)? – chacha Nov 06 '11 at 15:50
2

Enter in python Environment first

I am new to python and I guess this should be a rookie mistake.
I was running this line in my command line

from blogpost import db 

And I got the same error

can't read /var/mail/flaskblog

The problem was I did not enter in the Python environment and ran the python command.

Solution?
Enter in the python environment first

How to enter in python environment?
Type python or python3

python
from blogpost import db 

enter image description here

Rohit Singh
  • 16,950
  • 7
  • 90
  • 88