Unable to open x server error import c importimagecommand 359

Hello, Using miso on our cluster, I get: $ miso import: unable to open X server `' @ import.c/ImportImageCommand/359. import: unable to open X server `' @ import.c/ImportImageCommand/359. i...

Hi Olga,

The problem is that your shell is interpreting miso as a bash script instead of Python code, which is why you get all these crazy errors. How did you install MISO? When Python packages are installed with distribute easy_install or pip, the scripts of a package (like miso, compare_miso, etc.) get placed in a bin directory, which automatically has in its header the Python path in the first line. The Python package manager automatically makes these executable, and so there’s no need for changing permissions if the package is installed correctly. The scripts are typically put in ~/.local/bin/ and then all you need to do is have that path in your PATH environment variable so that you can get miso from the command line.

For example, if you go into the MISO directory and do:

$ easy_install --user -U .

or the equivalent pip command, scripts like miso will get placed in the bin directory I mentioned. If you do:

$ head -n 2 ~/.local/bin/miso

You should see that the first line has the path to your Python installation. What happens on your cluster when you do this?

$ python /home/yeo-lab/software/bin/miso --help

The errors you got are definitely the result of a mixup where miso gets executed as a bash script. My guess is that you’re not running the miso that’s in the bin directory (i.e. the installed miso script) but rather invoking bash on the github repository file miso which triggers these errors.

Update 1: I just saw that you had your installation commands in there. First, you don’t need the build command. Can you try easy_install in your directory or simply python setup.py install --prefix=~/ (or prefix to wherever your Python packages are)? Also, what is the output of this?

$ head /Library/Frameworks/EPD64.framework/Versions/Current/bin/miso

and this?

$ /Library/Frameworks/EPD64.framework/Versions/Current/bin/miso --help
$ python /Library/Frameworks/EPD64.framework/Versions/Current/bin/miso --help

I strongly recommend using distribute‘s easy_install or pip with local installation options to install your packages in ~/.local so that you have full control over which version is being used. Typing python setup.py install usually leads to Python path issues and related disasters.

Update 2: I just tried installing it on my Mac laptop with easy_install and this is what I get:

$ uname -a
Darwin 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386
$ git clone git@github.com:yarden/MISO
$ cd MISO/
$ sudo easy_install .

Then when I type miso, I get:

$ miso
MISO (Mixture of Isoforms model)
Probabilistic analysis of RNA-Seq data for detecting differential isoforms
Use --help argument to view options.

Using MISO settings file: /Library/Frameworks/EPD64.framework/Versions/7.0/lib/python2.7/site-packages/misopy-0.5.0-py2.7-macosx-10.5-x86_64.egg/misopy/settings/miso_settings.txt
$ which miso
/Library/Frameworks/EPD64.framework/Versions/Current/bin/miso

When it’s installed correctly, here’s what the executable miso script should look like:

$ which miso
/Library/Frameworks/EPD64.framework/Versions/Current/bin/miso
$ head /Library/Frameworks/EPD64.framework/Versions/Current/bin/miso
#!/Library/Frameworks/EPD64.framework/Versions/Current/bin/python
# EASY-INSTALL-SCRIPT: 'misopy==0.5.0','miso'
__requires__ = 'misopy==0.5.0'
import pkg_resources
pkg_resources.run_script('misopy==0.5.0', 'miso')

As you can see, easy_install made sure the miso file in ...Current/bin/miso is executable (I didn’t use chmod or anything like that) and it prepended the right #! path to the location of the Python on my machine.

I used sudo easy_install . since I have root access on my laptop obviously but in a cluster environment you should use --user for local installation into ~/.local.

  • Index
  • » Programming & Scripting
  • » [SOLVED] How to Programatically Capture Screenshot in a Linux Service

Pages: 1

#1 2018-07-30 04:03:25

tony5429
Member
Registered: 2006-03-28
Posts: 1,002

[SOLVED] How to Programatically Capture Screenshot in a Linux Service

I’m looking for a way to take a screenshot in a Linux service. This ImageMagick command works fine if I run it explicitly:

import -window root /home/bob/pic.png

But if I run it as a command called from a Linux service, I get this error:

import: unable to open X server `' @ error/import.c/ImportImageCommand/359.

I also tried prepending «export DISPLAY=:0.0» but that didn’t help…

Last edited by tony5429 (2018-07-31 14:29:23)

#2 2018-07-30 06:31:49

ayekat
Member
Registered: 2011-01-17
Posts: 1,553
Website

Re: [SOLVED] How to Programatically Capture Screenshot in a Linux Service

What is a «Linux service»? Do you mean a systemd service? If so, are you running the command from a system-wide service? If so, consider using a user service instead.

tony5429 wrote:

I also tried prepending «export DISPLAY=:0.0» but that didn’t help…

Where have you prepended that? Have you verified that the DISPLAY value for your session really is :0.0 (and not just :0)?

Also, what are really trying to do?


{,META,RE}PKGBUILDS │ pacman-hacks (includes makemetapkg and remakepkg) │ dotfileslocaldir

#3 2018-07-30 13:31:30

tony5429
Member
Registered: 2006-03-28
Posts: 1,002

Re: [SOLVED] How to Programatically Capture Screenshot in a Linux Service

Ah, yes I meant a systemd service — thanks. Unfortunately it does need to be a system-wide service.

I had prepended it like this:

export DISPLAY=:0.0 ; import -window root /home/bob/pic.png

Ah, you’re right; the DISPLAY value for my session is actually :0, but I just tried that and it also didn’t work…

No protocol specified
import: unable to open X server `:0' @ error/import.c/ImportImageCommand/359.

I think from reading this page that I need to do something with /home/bob/.xprofile and /home/bob/.Xauthority, but I’m not sure what exactly. This is for a project writing an open-source alternative to the software at accountable2you.com.

#4 2018-07-30 13:49:58

ayekat
Member
Registered: 2011-01-17
Posts: 1,553
Website

Re: [SOLVED] How to Programatically Capture Screenshot in a Linux Service

tony5429 wrote:

Unfortunately it does need to be a system-wide service.

Why? The X session runs under your user, so why shouldn’t the screenshot-capturing service run as your user? This seems needlessly complicated…

I had prepended it like this:

export DISPLAY=:0.0 ; import -window root /home/bob/pic.png

Yes, but where? If you put that line for ExecStart, this won’t work, because systemd doesn’t interpret the line like a shell (you’d need to wrap it into a sh -c ‘…’ wrapper). But more generally, check the COMMAND LINES section in systemd.service(5) for how to set environment variables in service files.

I think from reading this page that I need to do something with /home/bob/.xprofile and /home/bob/.Xauthority, but I’m not sure what exactly.

See https://wiki.archlinux.org/index.php/Sy … XAUTHORITY


{,META,RE}PKGBUILDS │ pacman-hacks (includes makemetapkg and remakepkg) │ dotfileslocaldir

#5 2018-07-30 14:04:07

N_BaH
Member
Registered: 2015-12-30
Posts: 77

Re: [SOLVED] How to Programatically Capture Screenshot in a Linux Service

hi,

what if X does not run? the service executes the script, but cannot find DISPLAY. hmm

why don’t you simply run the capture, inside an infinite loop checking for X to be running (if script doesn’t stop when desktop stops ( smile ), from kind-of-autostart ?

#6 2018-07-31 14:29:08

tony5429
Member
Registered: 2006-03-28
Posts: 1,002

Re: [SOLVED] How to Programatically Capture Screenshot in a Linux Service

@ayekat: OK, I read more about user services in the link you provided and realised that I’d been mistaken and that that really is a good solution for this effort. Switched it to a user service and that solved the problem. Thanks for your patience with me! Though irrelevant now, thanks for the other tips/info too. I’m using C and system() to wrap my shell commands.

#7 2018-07-31 14:34:56

ayekat
Member
Registered: 2011-01-17
Posts: 1,553
Website

Re: [SOLVED] How to Programatically Capture Screenshot in a Linux Service

I think it’s also worth checking out the suggestion made by N_BaH. If you launch the X session in some way (e.g. with xinit), you could also just start your screenshot program in there, no?

tony5429 wrote:

I’m using C and system() to wrap my shell commands.

I… I don’t think I want to know what exactly you’re doing there. neutral


{,META,RE}PKGBUILDS │ pacman-hacks (includes makemetapkg and remakepkg) │ dotfileslocaldir

#8 2018-07-31 14:40:45

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 27,833
Website

Re: [SOLVED] How to Programatically Capture Screenshot in a Linux Service

ayekat wrote:

tony5429 wrote:

I’m using C and system() to wrap my shell commands.

I… I don’t think I want to know what exactly you’re doing there. neutral

It’s like seeing someone who was grotesquely mutilated in some industrial accident.  You know you’re not supposed to stare, but you just can’t help it.  You know you shouldn’t ask about it, but you just feel you need to know.

In any case, it’s disturbing.


«UNIX is simple and coherent…» — Dennis Ritchie, «GNU’s Not UNIX» —  Richard Stallman

miso error: «Import: unable to open X server `’ @ import.c/ImportImageCommand/359» . #51

Comments

olgabot commented Jul 16, 2013

Hello,
Using miso on our cluster, I get:

I thought it might have been some incorrect compilation on our server-side, so I installed it in an environment where I have total control (my laptop), but I get the same error:

This is the exact same error as I get when I run just plain miso , without sudo . I tried sudo because I thought the error with can’t read /var/mail/misopy.parse_csv might be because of permissions.

Please let me know how I may correctly install MISO.

The text was updated successfully, but these errors were encountered:

yarden commented Jul 16, 2013

The problem is that your shell is interpreting miso as a bash script instead of Python code, which is why you get all these crazy errors. How did you install MISO? When Python packages are installed with distribute easy_install or pip , the scripts of a package (like miso , compare_miso , etc.) get placed in a bin directory, which automatically has in its header the Python path in the first line. The Python package manager automatically makes these executable, and so there’s no need for changing permissions if the package is installed correctly. The scripts are typically put in

/.local/bin/ and then all you need to do is have that path in your PATH environment variable so that you can get miso from the command line.

For example, if you go into the MISO directory and do:

or the equivalent pip command, scripts like miso will get placed in the bin directory I mentioned. If you do:

You should see that the first line has the path to your Python installation. What happens on your cluster when you do this?

The errors you got are definitely the result of a mixup where miso gets executed as a bash script. My guess is that you’re not running the miso that’s in the bin directory (i.e. the installed miso script) but rather invoking bash on the github repository file miso which triggers these errors.

Update 1: I just saw that you had your installation commands in there. First, you don’t need the build command. Can you try easy_install in your directory or simply python setup.py install —prefix=

/ (or prefix to wherever your Python packages are)? Also, what is the output of this?

I strongly recommend using distribute ‘s easy_install or pip with local installation options to install your packages in

/.local so that you have full control over which version is being used. Typing python setup.py install usually leads to Python path issues and related disasters.

Update 2: I just tried installing it on my Mac laptop with easy_install and this is what I get:

Then when I type miso , I get:

When it’s installed correctly, here’s what the executable miso script should look like:

As you can see, easy_install made sure the miso file in . Current/bin/miso is executable (I didn’t use chmod or anything like that) and it prepended the right #! path to the location of the Python on my machine.

I used sudo easy_install . since I have root access on my laptop obviously but in a cluster environment you should use —user for local installation into

Источник

Как получить скриншот с удаленной машины по ssh?

Захожу по ssh на удаленную машину. Иксы проброшены, иксовые приложения запускаются. По умолчанию дисплей — компьютер, с которого я захожу:

Вот так не получается:

Вот так тоже не получается:

Команды не работают ни от рута (от которого запущены иксы), ни от залогиненного в иксах пользователя, ни от другого пользователя.

Полное указание DISPLAY тоже не помогает:

При этом на удаленном компьютере (двухмониторная конфигурация) есть и :0.0, и :0.1.

Т.е. на удаленной машине иксы запущены? Тогда xhost +

И как я мышкой щелкну в удаленных иксах?

а если :0 попробовать?

Т.е. Вы его по ssh вводите? Так не получится. xhost должен выполнить процесс, уже имеющий доступ к иксам.

А дистанционно, что — никак нельзя?

А если иксы не пробрасывать? У меня нормально работало. И да, cat /var/log/Xorg.0.log|grep ‘>Screen’

Не знаю, я обычно записываю это в автозагрузку иксов/kdm/gdm и т.д. и перезапускаю их.

ваша целевая машинка случайно не пользует нвидаму?

ps auwex | grep DISPLAY кажет и DISPLAY=:0.0, и DISPLAY=:0.1, так что все ОК.

nVidia video card, with proprietary drivers.

Естественно. Как бы я еще двухмониторную конфигурацию сделал по-человечески?

man import, щёлкать необязательно.

Ну, с этого стоило начинать.
Когда-то имел проблемы с получением дисплея на аналогичной конфигурации.
Сейчас ничего толкового не скажу, я не дома и еду в отпуск (ура!), но если по памяти — они городят какой-то подводный костыль, который даёт 3й дисплей, а 0.0 и 0.1 вроде как и есть, но вроде как и нету.
Мрачно говорить об этом без деталей, но может сам накопаешь в эту сторону.

Источник

Arch Linux

You are not logged in.

#1 2018-07-30 04:03:25

[SOLVED] How to Programatically Capture Screenshot in a Linux Service

I’m looking for a way to take a screenshot in a Linux service. This ImageMagick command works fine if I run it explicitly:

But if I run it as a command called from a Linux service, I get this error:

I also tried prepending «export DISPLAY=:0.0» but that didn’t help.

Last edited by tony5429 (2018-07-31 14:29:23)

#2 2018-07-30 06:31:49

Re: [SOLVED] How to Programatically Capture Screenshot in a Linux Service

What is a «Linux service»? Do you mean a systemd service? If so, are you running the command from a system-wide service? If so, consider using a user service instead.

I also tried prepending «export DISPLAY=:0.0» but that didn’t help.

Where have you prepended that? Have you verified that the DISPLAY value for your session really is :0.0 (and not just :0)?

Online

#3 2018-07-30 13:31:30

Re: [SOLVED] How to Programatically Capture Screenshot in a Linux Service

Ah, yes I meant a systemd service — thanks. Unfortunately it does need to be a system-wide service.

I had prepended it like this:

Ah, you’re right; the DISPLAY value for my session is actually :0, but I just tried that and it also didn’t work.

I think from reading this page that I need to do something with /home/bob/.xprofile and /home/bob/.Xauthority, but I’m not sure what exactly. This is for a project writing an open-source alternative to the software at accountable2you.com.

#4 2018-07-30 13:49:58

Re: [SOLVED] How to Programatically Capture Screenshot in a Linux Service

Unfortunately it does need to be a system-wide service.

Why? The X session runs under your user, so why shouldn’t the screenshot-capturing service run as your user? This seems needlessly complicated.

I had prepended it like this:

Yes, but where? If you put that line for ExecStart, this won’t work, because systemd doesn’t interpret the line like a shell (you’d need to wrap it into a sh -c ‘. ‘ wrapper). But more generally, check the COMMAND LINES section in systemd.service(5) for how to set environment variables in service files.

I think from reading this page that I need to do something with /home/bob/.xprofile and /home/bob/.Xauthority, but I’m not sure what exactly.

Online

#5 2018-07-30 14:04:07

Re: [SOLVED] How to Programatically Capture Screenshot in a Linux Service

what if X does not run? the service executes the script, but cannot find DISPLAY.

why don’t you simply run the capture, inside an infinite loop checking for X to be running (if script doesn’t stop when desktop stops ( ), from kind-of-autostart ?

#6 2018-07-31 14:29:08

Re: [SOLVED] How to Programatically Capture Screenshot in a Linux Service

@ayekat: OK, I read more about user services in the link you provided and realised that I’d been mistaken and that that really is a good solution for this effort. Switched it to a user service and that solved the problem. Thanks for your patience with me! Though irrelevant now, thanks for the other tips/info too. I’m using C and system() to wrap my shell commands.

#7 2018-07-31 14:34:56

Re: [SOLVED] How to Programatically Capture Screenshot in a Linux Service

I think it’s also worth checking out the suggestion made by N_BaH. If you launch the X session in some way (e.g. with xinit), you could also just start your screenshot program in there, no?

I’m using C and system() to wrap my shell commands.

I. I don’t think I want to know what exactly you’re doing there.

Online

#8 2018-07-31 14:40:45

Re: [SOLVED] How to Programatically Capture Screenshot in a Linux Service

I’m using C and system() to wrap my shell commands.

I. I don’t think I want to know what exactly you’re doing there.

It’s like seeing someone who was grotesquely mutilated in some industrial accident. You know you’re not supposed to stare, but you just can’t help it. You know you shouldn’t ask about it, but you just feel you need to know.

In any case, it’s disturbing.

«UNIX is simple and coherent. » — Dennis Ritchie, «GNU’s Not UNIX» — Richard Stallman

Источник

linux — Imagemagick: PHP-скрипт, выдающий «импорт: невозможно открыть X-сервер»

Я пытаюсь захватить мое текущее окно, используя ImageMagick с использованием PHP-скрипта, но в ответ получил ошибку. Я искал его в stackoverflow, но никто из них не решил мою проблему. Я установил imagemagick на свою машину Ubuntu 14.04. Следующая команда дает мне правильный вывод.

У меня есть это в image.php

Я выполнил это из терминала

И я получил желаемый ответ (экран был захвачен, и файл получил имя screenshot.jpg)

Затем я попытался получить доступ к вышеупомянутому php-скрипту с помощью моего браузера. перерабатывать Команда отлично работает, но для Импортировать comamnd ничего не происходит, я попытался проверить мой журнал apache, и это дает мне следующую ошибку

Что мне здесь не хватает?

Это вопрос разрешения?

Решение

Если вы пытаетесь сделать это только для тестов и / или исследований:

1 — Проверьте, может ли пользователь apache запускать команды

2 — Проверьте, установлен ли и настроен ли X11, установите отображение env var. DISPLAY =: 0 например

3 — настроить команду импорта

/ usr / bin / import -window корень

в / usr / bin / import -window apache_user

или / usr / bin / import -window ваш_пользователь

Если вы пытаетесь создать веб-сайт, к которому будут обращаться несколько клиентов с разными операционными системами, ваш код не будет работать. Вам нужно будет сделать это, используя только PHP-код, потому что, очевидно, машина Windows не имеет команд convert и import.

Источник

`miso` error: «Import: unable to open X server `’ @ import.c/ImportImageCommand/359» . about miso HOT 1 OPEN

Comments (1)

The problem is that your shell is interpreting miso as a bash script instead of Python code, which is why you get all these crazy errors. How did you install MISO? When Python packages are installed with distribute easy_install or pip , the scripts of a package (like miso , compare_miso , etc.) get placed in a bin directory, which automatically has in its header the Python path in the first line. The Python package manager automatically makes these executable, and so there’s no need for changing permissions if the package is installed correctly. The scripts are typically put in

/.local/bin/ and then all you need to do is have that path in your PATH environment variable so that you can get miso from the command line.

For example, if you go into the MISO directory and do:

or the equivalent pip command, scripts like miso will get placed in the bin directory I mentioned. If you do:

You should see that the first line has the path to your Python installation. What happens on your cluster when you do this?

The errors you got are definitely the result of a mixup where miso gets executed as a bash script. My guess is that you’re not running the miso that’s in the bin directory (i.e. the installed miso script) but rather invoking bash on the github repository file miso which triggers these errors.

Update 1: I just saw that you had your installation commands in there. First, you don’t need the build command. Can you try easy_install in your directory or simply python setup.py install —prefix=

/ (or prefix to wherever your Python packages are)? Also, what is the output of this?

I strongly recommend using distribute ‘s easy_install or pip with local installation options to install your packages in

/.local so that you have full control over which version is being used. Typing python setup.py install usually leads to Python path issues and related disasters.

Update 2: I just tried installing it on my Mac laptop with easy_install and this is what I get:

Then when I type miso , I get:

When it’s installed correctly, here’s what the executable miso script should look like:

As you can see, easy_install made sure the miso file in . Current/bin/miso is executable (I didn’t use chmod or anything like that) and it prepended the right #! path to the location of the Python on my machine.

I used sudo easy_install . since I have root access on my laptop obviously but in a cluster environment you should use —user for local installation into

Related Issues (20)

  • version 0.5.4 vs 0.5.2 HOT 1
  • How to get SAM file?
  • Queries related to Bayes factor, Exon Co-ordinates
  • The Python Apocalypse leads to Documentation Bug
  • Installation error: setting file does not exist
  • sam_utils.py problem
  • About testing error HOT 1
  • RuntimeWarning
  • RuntimeWarning: Long deleted alignment at pysplicing/src/solve.c:281 HOT 1
  • ValueError: numpy.dtype has the wrong size, try recompiling. Expected 88, got 96 HOT 1
  • Unstable running results.
  • Only works with samtools HOT 5
  • No events captured during compare differential isoforms
  • annotation file links not working HOT 1
  • index_gff killed with no explanation
  • which part should I modify?
  • ValueError: too many values to unpack
  • Alternative Splicing Events annotations download link is erro HOT 2
  • different maximum values of y-axis for different samples in one plot

Recommend Projects

React

A declarative, efficient, and flexible JavaScript library for building user interfaces.

Vue.js

🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

Typescript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

TensorFlow

An Open Source Machine Learning Framework for Everyone

Django

The Web framework for perfectionists with deadlines.

Laravel

A PHP framework for web artisans

Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

javascript

JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

Some thing interesting about web. New door for the world.

server

A server is a program made to process requests and deliver data to clients.

Machine learning

Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

Visualization

Some thing interesting about visualization, use data art

Some thing interesting about game, make everyone happy.

Recommend Org

Facebook

We are working to build community through open source technology. NB: members must have two-factor auth.

Microsoft

Open source projects and samples from Microsoft.

Источник

Task error return code 2

Hi

When running my Python script in console there is no error encountered but when it run in Task it hit below error

import-im6.q16: unable to open X server ' @
error/import.c/ImportImageCommand/359. import-im6.q16: unable to open
X server
‘ @ error/import.c/ImportImageCommand/359. import-im6.q16:
unable to open X server ' @ error/import.c/ImportImageCommand/359.
/home/okl/ibox_wkly_svs_lvl: line 6: try:: command not found
/home/okl/ibox_wkly_svs_lvl: line 7: syntax error near unexpected
token
(‘ /home/okl/ibox_wkly_svs_lvl: line 7: ` mydb =
connection.connect(host=»Xxx.mysql.database.azure.com», database =
‘ibox_depo’,user=»Xxxx@xxxx», passwd=»!xxx@»,use_pure=True)’

2021-11-03 11:33:06 — Completed task, took 2.50 seconds, return code
was 2.

okl
|
11
posts
|



Nov. 3, 2021, 11:46 a.m.

|
permalink

Solved thanks

okl
|
11
posts
|



Nov. 3, 2021, 11:57 p.m.

|
permalink

Thanks for confirming that!

Staff

pafk
|
2441
posts
|

PythonAnywhere staff
|



Nov. 4, 2021, 11:19 a.m.

|
permalink

Я получаю следующие ошибки при попытке запустить часть кода Python:

import: unable to open X server `' @ error/import.c/ImportImageCommand/366.
from: can't read /var/mail/datetime
./mixcloud.py: line 3: syntax error near unexpected token `('
./mixcloud.py: line 3: `now = datetime.now()'

Код:

import requests
from datetime import datetime,date,timedelta

now = datetime.now()

Я действительно не вижу проблемы. Это проблема с моим сервером, а не с самим кодом?

4 ответы

это ошибки вашей командной оболочки. вы запускаете код через оболочку, а не через python.

попробуйте интерпретатор Python;)

$ 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()
>>> 

если вы используете скрипт, вы можете вызывать напрямую с помощью python:

$ python mixcloud.py

в противном случае убедитесь, что он начинается с правильной строки shebang:

#!/usr/bin/env python

… и затем вы можете вызвать его только по имени (при условии, что он помечен как исполняемый):

$ ./mixcloud.py

ответ дан 22 окт ’13, 01:10

Проверьте, является ли ваш #! строка находится в первой строке вашего файла Python. Я получил эту ошибку, потому что я поместил эту строку во вторую строку файла.

ответ дан 27 мар ’17, в 22:03

вы можете добавить следующую строку в начало вашего скрипта Python

#!/usr/bin/env python3

ответ дан 23 апр.

Я получил эту ошибку, когда попытался запустить свой скрипт Python на докере с помощью запуск докеров. Убедитесь в этом случае, что установленная вами точка входа установлена ​​правильно:

--entrypoint /usr/bin/python

Создан 14 фев.

Не тот ответ, который вы ищете? Просмотрите другие вопросы с метками

python

or задайте свой вопрос.

Я получаю следующие ошибки при попытке запустить кусок кода Python:

import: unable to open X server `' @ error/import.c/ImportImageCommand/366.
from: can't read /var/mail/datetime
./mixcloud.py: line 3: syntax error near unexpected token `('
./mixcloud.py: line 3: `now = datetime.now()'

Код:

import requests
from datetime import datetime,date,timedelta

now = datetime.now()

Мне действительно не хватает проблемы. Это проблема с моим сервером, а не сам код?

3 ответа

Лучший ответ

Это ошибки вашей командной оболочки. вы запускаете код через оболочку, а не через python.

Попробуй из интерпретатора питона;)

$ 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()
>>> 

Если вы используете скрипт, вы можете вызвать напрямую через python:

$ python mixcloud.py

В противном случае убедитесь, что он начинается с правильной строки shebang:

#!/usr/bin/env python

… и затем вы можете вызвать его только по имени (при условии, что он помечен как исполняемый):

$ ./mixcloud.py


71

Corey Goldberg
22 Окт 2013 в 00:46

Я получил эту ошибку, когда попытался запустить скрипт Python в Docker с помощью Docker Run . Убедитесь, что в этом случае вы правильно установили точку входа:

--entrypoint /usr/bin/python


0

misi
14 Фев 2018 в 01:21

Проверьте, находится ли ваша строка #! в первой строке вашего файла Python. Я получил эту ошибку, потому что я поместил эту строку во вторую строку файла.


7

Izana
27 Мар 2017 в 21:52

Понравилась статья? Поделить с друзьями:
  • Unable to open the fifa fat file как исправить
  • Unable to open physical file operating system error 5
  • Unable to install asus splendid video enhancement technology error number could not find icm file
  • Unable to initialize vulkan graphics subsystem xenia как исправить
  • Unable to open item for playback object not found как исправить ошибку