Getting Python error “from: can't read /var/mail/Bio”

后端 未结 6 1955
长发绾君心
长发绾君心 2020-12-24 11:42

I am running a (bio)python script which results in the following error:

from: can\'t read /var/mail/Bio

seeing as my script doesn\'t have a

相关标签:
6条回答
  • 2020-12-24 11:50

    Same here. I had this error when running an import command from terminal without activating python3 shell through manage.py in a django project (yes, I am a newbie yet). As one must expect, activating shell allowed the command to be interpreted correctly.

    ./manage.py shell
    

    and only then

    >>> from django.contrib.sites.models import Site
    
    0 讨论(0)
  • 2020-12-24 11:51

    I ran into a similar error

    "from: can't read /var/mail/django.test.utils"

    when trying to run a command

    >>> from django.test.utils import setup_test_environment
    >>> setup_test_environment()
    

    in the tutorial at https://docs.djangoproject.com/en/1.8/intro/tutorial05/

    after reading the answer by Tamás I realized I was not trying this command in the python shell but in the termnial (this can happen to those new to linux)

    solution was to first enter in the python shell with the command python and when you get these >>> then run any python commands

    0 讨论(0)
  • 2020-12-24 11:51

    for Mac OS just go to applications and just run these Scripts Install Certificates.command and Update Shell Profile.command, now it will work.

    0 讨论(0)
  • 2020-12-24 11:55

    No, it's not the script, it's the fact that your script is not executed by Python at all. If your script is stored in a file named script.py, you have to execute it as python script.py, otherwise the default shell will execute it and it will bail out at the from keyword. (Incidentally, from is the name of a command line utility which prints names of those who have sent mail to the given username, so that's why it tries to access the mailboxes).

    Another possibility is to add the following line to the top of the script:

    #!/usr/bin/env python
    

    This will instruct your shell to execute the script via python instead of trying to interpret it on its own.

    0 讨论(0)
  • 2020-12-24 11:59

    I got same error because I was trying to run on

    XXX-Macmini:Python-Project XXX.XXX$ from classDemo import MyClass
    
    from: can't read /var/mail/classDemo
    

    To solve this, type command python and when you get these >>> then run any python commands

    >>>from classDemo import MyClass
    >>>f = MyClass()
    
    0 讨论(0)
  • 2020-12-24 12:01

    Put this at the top of your .py file (for python 2.x)

    #!/usr/bin/env python 
    

    or for python 3.x

    #!/usr/bin/env python3
    

    This should look up the python environment, without it, it will execute the code as if it were not python code, but straight to the CLI. If you need to specify a manual location of python environment put

    #!/#path/#to/#python
    
    0 讨论(0)
提交回复
热议问题