deep_learning_keras, Spacy Example, SystemExit:2 running in Jupyter/Colab - python

My overall aim is to run the Deep_Learning_keras which is a SpaCy example in Google Colab (ie in Jupyter Notebooks)
The GitHub link to the Deep_Learning_keras SpaCy example is:https://github.com/explosion/spaCy/blob/master/examples/deep_learning_keras.py
When I ran the example code directly in Google Colab I got the following error:
usage: ipykernel_launcher.py [-h] [-r] [-H 64] [-L 100] [-d 0.5] [-e 0.001]
[-i 5] [-b 256] [-n -1][model_dir] [train_dir] [dev_dir]
ipykernel_launcher.py: error: unrecognized arguments: -f
An exception has occurred, use %tb to see the full traceback.
SystemExit: 2
I understand that the example was originally written for python and that running the copy in a Jupyter Notebook environment is not entirely compatible. I'm not sure what code/statements I need to change in the example to make it compatible
I did a google search for the SystemExit: 2 error and the closest example I found was (however the problem within the SystemExit: 2 is different to my problem):
SystemExit: 2 error when calling parse_args() in iPython Notebook
Thanks

Related

What is the usage of the flag '--use_env' while parsing some command line arguments in python?

I am referring a git repository which uses following bash file for starting the training of a neural network. I want to understand the use of '--use_env' flag.
#! /bin/bash
CUDA_VISIBLE_DEVICES=2 python -m torch.distributed.launch --nproc_per_node=1 --master_port 2351 --use_env train.py --dataroot SOME_PATH_TO_DATA
In the above command, what is the importance of '--use_env' flag? I have also checked that if I remove that flag, I get error saying "train.py: error: unrecognized arguments: -m torch.distributed.launch" as shown below.
train.py: error: unrecognized arguments: -m torch.distributed.launch
I am not able to find any relevant resources to know more about these flags. Could anyone please help me understand the use of this flag or suggest any resources to refer to?

How do I use the "virtualenv.cli_run" method in a Python script to create a virtual environment?

I have a Python script that creates a virtual environment in the following way:
import os
import subprocess
virtualenv_path = os.path.join("/tmp", "my-environment")
subprocess.run(["virtualenv", virtualenv_path], check=True)
This works just fine. However in the Virtualenv documentation I saw that you can "trigger invocation of Python environments from within Python". To do this "you should be using the virtualenv.cli_run method; this takes an args argument where you can pass the options the same way you would from the command line. The run will return a session object containing data about the created virtual environment."
So I ran the following instead:
from virtualenv import cli_run
cli_run(["virtualenv", "/tmp/my-environment"])
However this gives me the following error:
usage: virtualenv [--version] [--with-traceback] [-v | -q] [--read-only-app-data] [--app-data APP_DATA] [--reset-app-data] [--upgrade-embed-wheels] [--discovery {builtin}] [-p py] [--try-first-with py_exe]
[--creator {builtin,cpython3-posix,venv}] [--seeder {app-data,pip}] [--no-seed] [--activators comma_sep_list] [--clear] [--no-vcs-ignore] [--system-site-packages] [--symlinks | --copies] [--no-download | --download]
[--extra-search-dir d [d ...]] [--pip version] [--setuptools version] [--wheel version] [--no-pip] [--no-setuptools] [--no-wheel] [--no-periodic-update] [--symlink-app-data] [--prompt prompt] [-h]
dest
virtualenv: error: unrecognized arguments: /tmp/my-environment
An exception has occurred, use %tb to see the full traceback.
SystemExit: 2
I am really unsure about why this doesn't work as I am passing the same arguments as I would on the command line.
When you call cli_run as part of virtualenv, you don't need to include the program name, in this case "virtualenv". Simply include your destination, along with any other arguments.

Error executing Jupyter command 'notebook': [Errno 2] No such file or directory, how to solve it?

I am installing jupyter notebook in my Ubuntu 18.04/Python 3.6 machine using such way, however, when I tried to use jupyter notebook to excute notebook,following error occured:
Error executing Jupyter command 'notebook': [Errno 2] No such file or directory
if I use jupyter -h,following info will be printed:
usage: jupyter [-h] [--version] [--config-dir] [--data-dir] [--runtime-dir]
[--paths] [--json]
[subcommand]
Jupyter: Interactive Computing
positional arguments:
subcommand the subcommand to launch
optional arguments:
-h, --help show this help message and exit
--version show the jupyter command's version and exit
--config-dir show Jupyter config dir
--data-dir show Jupyter data dir
--runtime-dir show Jupyter runtime dir
--paths show all Jupyter paths. Add --json for machine-readable
format.
--json output paths as machine-readable json
Available subcommands: migrate troubleshoot
I have google a lot but can't find the solution.And I have tried all of the answers below this question, none of them can solve my question.Is there anyone can help me?Thanks a lot.

is there a solution for conftest python file error

I am getting this error when I run login_tests.py
(venv) C:\Users\PRAGITI\PycharmProjects\lrtskodeit\tests>py.test Home/login_tests.py --browser chrome
ERROR: usage: py.test [options] [file_or_dir] [file_or_dir] [...]
py.test: error: unrecognized arguments: --browser chrome
inifile: None
rootdir: C:\Users\PRAGITI\PycharmProjects\lrtskodeit\tests
(venv) C:\Users\PRAGITI\PycharmProjects\lrtskodeit\tests>
From the error, I could ascertain that you have not added the command line argument "browser" in your pytest.addoption().
However, IF the above solution is not useful, then it would be helpful if you provide your script content.

Error when trying to use memory_profiler module

I am trying to use the memory_profiler module to profile the memory usage of a large Python program. There seems to be a memory leak somewhere in my program, so I'm hoping this module will help me find the leak.
I installed memory_profiler using pip and tested it with the sample code provided here. This works perfectly.
When I try to use it with my program, I add the #profile decorator to my main() function and run the profiler from the command line the same way:
$ python -m memory_profiler engine.py
I get the following error, and my program fails to run (everything hangs):
usage: memory_profiler.py [-h] [-c CHARSET] [-i] [-o] [-l LOG_LEVEL] [-g] [-k]
[-w] [-s STOP] [-x TEXTS] [-z SIZE] [-t TIMEOUT]
[-p] [-d DEVICE]
memory_profiler.py: error: unrecognized arguments: engine.py
Any ideas what I might be doing wrong?

Categories

Resources