Python error “import: unable to open X server”

前端 未结 3 439
北荒
北荒 2020-12-30 18:28

I am getting the following errors when trying to run a piece of python code:

import: unable to open X server `\' @ error/import.c/ImportImageCommand/366.
fro         


        
相关标签:
3条回答
  • 2020-12-30 19:12

    I got this error when I tried to run my python script on docker with docker run. Make sure in this case that you set the entry point is set correctly:

    --entrypoint /usr/bin/python
    
    0 讨论(0)
  • 2020-12-30 19:18

    Check whether your #! line is in the first line of your python file. I got this error because I put this line into the second line of the file.

    0 讨论(0)
  • 2020-12-30 19:20

    those are errors from your command shell. you are running code through the shell, not python.

    try from a python interpreter ;)

    $ python
    Python 2.7.5+ (default, Sep 19 2013, 13:48:49) 
    [GCC 4.8.1] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import requests
    >>> from datetime import datetime,date,timedelta
    >>> 
    >>> now = datetime.now()
    >>> 
    

    if you are using a script, you may invoke directly with python:

    $ python mixcloud.py
    

    otherwise, ensure it starts with the proper shebang line:

    #!/usr/bin/env python
    

    ... and then you can invoke it by name alone (assuming it is marked as executable):

    $ ./mixcloud.py
    
    0 讨论(0)
提交回复
热议问题