When I run this command:
FLASK_APP=web.py flask run
I get this error:
File "<ipython-input-2-26c34e6a35fe>", line 1
FLASK_APP=web.py flask run
^
SyntaxError: invalid syntax
What am I missing?
You seem to be running a terminal command inside ipython based on the error message.
The problem with this is that you haven't told ipython that you're trying to run a terminal command.
In Jupyter Notebook you can execute Terminal commands in the notebook cells by prepending an exclamation point/bang(!) to the beginning of the command.
source
So do this instead:
!FLASK_APP=web.py flask run
Related
I am having this issue when trying to run ng test for a component that I've created.
I tried opening in integrated terminal, open a cmd terminal and try there and other things to but I always get that error.
src\apps\some-portal\src\app\created-component this would be the path.
Also tried to run from src and I have the same problem.
I want to run Selenium in AWS, specifically in a Lambda function. The Lambda function should use a Docker Image, which is stored on Amazon ECR. The Selenium code is simple Demo code in Python.
When I run a Docker Container from my image locally, everything works fine and Selenium succeeds, but when I deploy the image to AWS and configure the lambda function to use it, it fails and throws this error:
selenium.common.exceptions.WebDriverException: Message: unknown error: unable to discover open window in chrome
I have already tried all possible chrome driver arguments and even tried the solutions from this question:
Aws Lambda Ruby Crawler selenium chrome driver: 'unknown error: unable to discover open window in chrome'
Nothing seems to work. The error doesn't disappear.
I have used different browsers including google-chrome-stable, firefox, headless-chromium with different versions, all fail in aws, but work in a local docker container.
I also tried to deploy a Debian image with the required dependencies instead of aws-lambda-python, but it also throws the same error.
Currently I am using Google Chrome Version 91, chromedriver 91.0.4472.101 for linux64 and selenium 3.141.0.
The Dockerfile looks like this:
FROM amazon/aws-lambda-python:3.8
RUN curl https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm > google-chrome-stable_current_x86_64.rpm
RUN yum install ./google-chrome-stable_current_x86_64.rpm -y
RUN pip install selenium
COPY . ./
CMD [ "main.py" ]
ENTRYPOINT [ "python" ]
main.py:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
if __name__ == '__main__':
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("--disable-application-cache")
chrome_options.add_argument("--disable-infobars")
chrome_options.add_argument("--no-sandbox")
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument("--hide-scrollbars")
chrome_options.add_argument("--enable-logging")
chrome_options.add_argument("--single-process")
chrome_options.add_argument("--ignore-certificate-errors")
chrome_options.add_argument("--homedir=/tmp")
chrome_options.add_argument("--log-level=0")
driver = webdriver.Chrome(executable_path="/var/task/chromedriver", options=chrome_options)
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()
print("done")
Directory Structure
EDIT 1: I have tried using the selenium/standalone-chrome and selenium/standalone-firefox image like Moshe Slavin suggested. On chrome, I am now getting a different error with the same options (pages instead of window):
selenium.common.exceptions.WebDriverException: Message: unknown error: unable to discover open pages
On firefox I get this error. Exactly the same error before using the selenium image:
selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status signal
i used git clone https://github.com/django-oscar/django-oscar, then i used
pipenv install
and i got
AttributeError: module 'os' has no attribute 'uname' this error as well as this
pipenv.patched.notpip._internal.exceptions.InstallationError:
Command errored out with exit status 1:
python setup.py egg_info Check the logs for full command output.
I am using windows 10.
I guess this does not have a lot to do with docker but more with the host OS (win 10 in this case).
This question describes in more detail but it comes down to the fact that uname is not available on windows. Since docker containers use the kernels from the host OS they are run on, in your case this will error out.
The same error will appear if you run these commands in Windows 10 under the python Idle environment.
I am trying to run a wxpython script via VNC. When i try to open it i get the error:
X11 connection rejected because of wrong authentication.
Unable to access the X Display, is $DISPLAY set properly?
I solve it via:
xauth list
sudo xauth add raspberrypi/unix:10 MIT-MAGIC-COOKIE-1
and then the corresponding cookie. Thing is i wanted to automate this in the init of the script, so that the user would not need to do it every time. i have written the following script:
import subprocess
import string
p=subprocess.Popen(['xauth','list'],stdout=subprocess.PIPE)
(out,err)=p.communicate()
out1=out.split('\n')
for line in out1:
t=line.split()
y=subprocess.Popen(['sudo','xauth','add',t[0],t[1],t[2]],stdout=subprocess.PIPE)
which works fine but i am still not able to get the program to run. Checking the output i realize that i am not getting the same output if i run xauth list from shell and if i run it with Popen.
Any help would be much appreciated!
I'm trying to run IPython on a production ubuntu server. I want to control it with upstart.
I have a bash script that properly invokes it in the foreground but it doesn't work when invoked through upstart. I'm not sure how to debug the problem other than piping the upstart script's output to a file, which just confirms that the IPython console dashboard properly shows up.
I'm using django-extensions with the following configuration:
IPYTHON_ARGUMENTS = [
'--ext', 'django_extensions.management.notebook_extension',
'--pylab=inline',
'--profile=myprofile',
]
My bash script is:
#!/bin/bash
set -e
cd /home/ubuntu/myproject
exec venv/bin/python /home/ubuntu/myproject/manage.py shell_plus --notebook
Any help is appreciated
No idea what can be the reason.
Did you had a look at Hydra that have been designed to launch multiple IPython server?