这条消息是什么意思?来自:无法读取/ var / mail / ex48(学习Python的艰难之路ex49)

时间:2021-10-16 12:59:55

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

在ex49中,我们被告知使用以下命令调用ex48中创建的lexicon.py文件。

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?

我试过看了。这是什么意思?文件是在错误的地方吗?

2 个解决方案

#1


23  

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.

您需要将shebang添加到程序的第一行。放入#!/ usr / bin / python或者你的python bin所在的地方,你的程序将运行。

#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.

你没有在Python shell中输入“来自ex48 import lexicon”,你在命令行输入了它。 “from”是列出邮件来自的命令,因此是/ var / mail位置。

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

#1


23  

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.

您需要将shebang添加到程序的第一行。放入#!/ usr / bin / python或者你的python bin所在的地方,你的程序将运行。

#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.

你没有在Python shell中输入“来自ex48 import lexicon”,你在命令行输入了它。 “from”是列出邮件来自的命令,因此是/ var / mail位置。

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