Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to run on windows, can't run yarn commands #222

Open
naveedulislam opened this issue Apr 3, 2018 · 12 comments
Open

Fails to run on windows, can't run yarn commands #222

naveedulislam opened this issue Apr 3, 2018 · 12 comments
Labels
help wanted windows Microsoft Windows issues

Comments

@naveedulislam
Copy link

When I run this example code:

from bowtie.visual import Plotly
from bowtie.control import Nouislider
import numpy as np
import plotlywrapper as pw

sine_plot = Plotly()
freq_slider = Nouislider(caption='frequency', minimum=1, maximum=10, start=5)

def listener(freq):
    freq = float(freq[0])
    t = np.linspace(0, 10, 100)
    sine_plot.do_all(pw.line(t, np.sin(freq * t)).dict)

from bowtie import command
@command
def main():
    from bowtie import App
    app = App()
    app.add_sidebar(freq_slider)
    app.add(sine_plot)
    app.subscribe(listener, freq_slider.on_change)
    return app

I receive an error message:

NoSuchOption                              Traceback (most recent call last)
C:\Anaconda3\lib\site-packages\click\parser.py in _process_opts(self, arg, state)
    413         try:
--> 414             self._match_long_opt(norm_long_opt, explicit_value, state)
    415         except NoSuchOption:

C:\Anaconda3\lib\site-packages\click\parser.py in _match_long_opt(self, opt, explicit_value, state)
    323                              if word.startswith(opt)]
--> 324             raise NoSuchOption(opt, possibilities=possibilities)
    325 

NoSuchOption: no such option: -f

During handling of the above exception, another exception occurred:

NoSuchOption                              Traceback (most recent call last)
C:\Anaconda3\lib\site-packages\click\core.py in main(self, args, prog_name, complete_var, standalone_mode, **extra)
    695             try:
--> 696                 with self.make_context(prog_name, args, **extra) as ctx:
    697                     rv = self.invoke(ctx)

C:\Anaconda3\lib\site-packages\click\core.py in make_context(self, info_name, args, parent, **extra)
    620         with ctx.scope(cleanup=False):
--> 621             self.parse_args(ctx, args)
    622         return ctx

C:\Anaconda3\lib\site-packages\click\core.py in parse_args(self, ctx, args)
   1017 
-> 1018         rest = Command.parse_args(self, ctx, args)
   1019         if self.chain:

C:\Anaconda3\lib\site-packages\click\core.py in parse_args(self, ctx, args)
    875         parser = self.make_parser(ctx)
--> 876         opts, args, param_order = parser.parse_args(args=args)
    877 

C:\Anaconda3\lib\site-packages\click\parser.py in parse_args(self, args)
    266         try:
--> 267             self._process_args_for_options(state)
    268             self._process_args_for_args(state)

C:\Anaconda3\lib\site-packages\click\parser.py in _process_args_for_options(self, state)
    292             elif arg[:1] in self._opt_prefixes and arglen > 1:
--> 293                 self._process_opts(arg, state)
    294             elif self.allow_interspersed_args:

C:\Anaconda3\lib\site-packages\click\parser.py in _process_opts(self, arg, state)
    422             if arg[:2] not in self._opt_prefixes:
--> 423                 return self._match_short_opt(arg, state)
    424             if not self.ignore_unknown_options:

C:\Anaconda3\lib\site-packages\click\parser.py in _match_short_opt(self, arg, state)
    366                     continue
--> 367                 raise NoSuchOption(opt)
    368             if option.takes_value:

NoSuchOption: no such option: -f

During handling of the above exception, another exception occurred:

UnsupportedOperation                      Traceback (most recent call last)
<ipython-input-51-d9c40d8b7316> in <module>()
     13 
     14 from bowtie import command
---> 15 @command
     16 def main():
     17     from bowtie import App

C:\Anaconda3\lib\site-packages\bowtie\_command.py in command(func)
    124             arg = ('--help',)
    125         # pylint: disable=too-many-function-args
--> 126         sys.exit(cmd(arg))
    127 
    128     return cmd

C:\Anaconda3\lib\site-packages\click\core.py in __call__(self, *args, **kwargs)
    720     def __call__(self, *args, **kwargs):
    721         """Alias for :meth:`main`."""
--> 722         return self.main(*args, **kwargs)
    723 
    724 

C:\Anaconda3\lib\site-packages\click\core.py in main(self, args, prog_name, complete_var, standalone_mode, **extra)
    705                 if not standalone_mode:
    706                     raise
--> 707                 e.show()
    708                 sys.exit(e.exit_code)
    709             except IOError as e:

C:\Anaconda3\lib\site-packages\click\exceptions.py in show(self, file)
     46             color = self.ctx.color
     47             echo(self.ctx.get_usage() + '\n', file=file, color=color)
---> 48         echo('Error: %s' % self.format_message(), file=file, color=color)
     49 
     50 

C:\Anaconda3\lib\site-packages\click\utils.py in echo(message, file, nl, err, color)
    257 
    258     if message:
--> 259         file.write(message)
    260     file.flush()
    261 

UnsupportedOperation: not writable
@jwkvam
Copy link
Owner

jwkvam commented Apr 3, 2018

Can you show me the output when you run pip freeze, you can paste it here if you like. I think you may have an old version of click but I'm not sure. The fix here is that I should specify a minimum version for it but I never bothered to figure it out. Could you also tell me what command you ran for example:

./app.py build

or

./app.py run

?

I'm using click version 6.7for example, the tests only run against the latest version. You can try:

pip install -U click

Thanks for the report by the way!

@naveedulislam
Copy link
Author

naveedulislam commented Apr 4, 2018

Ok, I found my mistake, as I had not read the documentation carefully and just tried to run the code off Jupyter Notebook without making the required changes. This time I made recommended changes like so:

from bowtie.visual import Plotly
from bowtie.control import Nouislider
import numpy as np
import plotlywrapper as pw

sine_plot = Plotly()
freq_slider = Nouislider(caption='frequency', minimum=1, maximum=10, start=5)

def listener(freq):
    freq = float(freq[0])
    t = np.linspace(0, 10, 100)
    sine_plot.do_all(pw.line(t, np.sin(freq * t)).dict)

from bowtie import command

def main():
    from bowtie import App
    app = App()
    %bowtie app
    app.add_sidebar(freq_slider)
    app.add(sine_plot)
    app.subscribe(listener, freq_slider.on_change)
    return app

and ran it and did not get any errors. But when I tried to reach the local host ny using:

http://localhost:9991/

I found this:

This site can’t be reached
localhost refused to connect.
Search Google for localhost 9991
ERR_CONNECTION_REFUSED

I also tried to run the example off command line as well after making sure that I had the correct version of click installed and encountered the below error:

Traceback (most recent call last):
  File "app.py", line 15, in <module>
    @command
  File "C:\Anaconda3\lib\site-packages\bowtie\_command.py", line 126, in command
    sys.exit(cmd(arg))
  File "C:\Anaconda3\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "C:\Anaconda3\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "C:\Anaconda3\lib\site-packages\click\core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Anaconda3\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Anaconda3\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "C:\Anaconda3\lib\site-packages\bowtie\_command.py", line 84, in run
    _build(app)
  File "C:\Anaconda3\lib\site-packages\bowtie\_command.py", line 42, in _build
    app._build()
  File "C:\Anaconda3\lib\site-packages\bowtie\_app.py", line 875, in _build
    if run(['yarn', 'install'], notebook=notebook) > 1:
  File "C:\Anaconda3\lib\site-packages\bowtie\_app.py", line 897, in run
    return Popen(command, cwd=_DIRECTORY).wait()
  File "C:\Anaconda3\lib\subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "C:\Anaconda3\lib\subprocess.py", line 997, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

@jwkvam
Copy link
Owner

jwkvam commented Apr 4, 2018

Can you check if you have yarn installed? Bowtie needs to be able to run yarn from the command line. The Jupyter integration is still somewhat fragile at this point. The command line interface should be relatively robust.

https://yarnpkg.com/en/docs/install#windows

Maybe I can improve the error messaging here in case people don't have yarn installed.

@naveedulislam
Copy link
Author

naveedulislam commented Apr 4, 2018

  1. Though I was sure that I had installed Yarn using:
    conda install -c conda-forge yarn
    but I reinstalled it and tried to run the file from Jupyter Notebook but did not get any response.

  2. Then I installed Yarn using .msi (from https://yarnpkg.com/en/docs/install#windows) file and tried to run the code in Jupyter Notebook again. Sill no response.

  3. Lastly, I tried to run the file from command line as:
    python app3.py run
    I again received the same error message as provided in my last comment.
    Note that I ran the file on CLI on a different computer this time just to rule out any environmental issues with all new installs of all required elements as prescribed in:
    https://bowtie-py.readthedocs.io/en/latest/quickstart.html

@jwkvam
Copy link
Owner

jwkvam commented Apr 4, 2018

@naveedulislam Hmm, maybe I was mistaken. Can you run yarn from the command line?

It might be worth noting that I don't have access to a windows machine so I've never tried it myself. As far as I know I don't think bowtie is doing anything that would prohibit usage on windows.

@naveedulislam
Copy link
Author

Since you did not prescribe what I should run for yarn from the command line so I assume that your query for me was to see whether yarn could be run for any command on a windows computer?
I ran the below anaconda command within CMD:
yarn add bowtie
It did run successfully without any unexpected errors:

(C:\Anaconda3) C:\Users\navee\Syncplicity\01-Charter>yarn add bowtie
yarn add v1.5.1
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 26 new dependencies.
info Direct dependencies
└─ [email protected]
info All dependencies
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
└─ [email protected]
Done in 4.01s.

Then I ran the command:

python app.py run

The rsult:

(C:\Anaconda3) C:\Users\navee\Syncplicity\01-Charter>python app.py run
Traceback (most recent call last):
  File "app.py", line 15, in <module>
    @command
  File "C:\Anaconda3\lib\site-packages\bowtie\_command.py", line 126, in command
    sys.exit(cmd(arg))
  File "C:\Anaconda3\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "C:\Anaconda3\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "C:\Anaconda3\lib\site-packages\click\core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Anaconda3\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Anaconda3\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "C:\Anaconda3\lib\site-packages\bowtie\_command.py", line 84, in run
    _build(app)
  File "C:\Anaconda3\lib\site-packages\bowtie\_command.py", line 42, in _build
    app._build()
  File "C:\Anaconda3\lib\site-packages\bowtie\_app.py", line 875, in _build
    if run(['yarn', 'install'], notebook=notebook) > 1:
  File "C:\Anaconda3\lib\site-packages\bowtie\_app.py", line 897, in run
    return Popen(command, cwd=_DIRECTORY).wait()
  File "C:\Anaconda3\lib\subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "C:\Anaconda3\lib\subprocess.py", line 997, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified


@jwkvam
Copy link
Owner

jwkvam commented Apr 6, 2018

I wonder if there is some weird pathing going on. You can run yarn from the command line but it seems like you can't run it through a python subprocess call? Can you please run this from the command line to confirm this?

python -c "import subprocess; subprocess.Popen(['yarn', '--version'])"

Thank you for trudging through this with me. I wish we had a faster way to debug this. I haven't heard experiences from Windows users before, maybe this tells me that setting up appveyor is worth it.

@naveedulislam
Copy link
Author

I tried and below is the result:

(base) C:\Users\navee>python -c "import subprocess; subprocess.Popen(['yarn', '--version'])"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Anaconda3\lib\subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "C:\Anaconda3\lib\subprocess.py", line 997, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

(base) C:\Users\navee>

@jwkvam jwkvam changed the title Cannot run the example code Fails to run on windows, can't run yarn commands Apr 6, 2018
@jwkvam
Copy link
Owner

jwkvam commented Apr 6, 2018

Okay problem is confirmed! If we can solve this, then I think everything else will be resolved. I'll think about for this a bit. In the meantime if anyone using Windows reads this, please chime in if you know how to solve this!

@jwkvam jwkvam added help wanted windows Microsoft Windows issues labels Apr 6, 2018
@jwkvam
Copy link
Owner

jwkvam commented Apr 6, 2018

@naveedulislam Can you try some of the "solutions" here. For example:

python -c "import subprocess; subprocess.Popen(['yarn --version'], shell=True)"

@naveedulislam
Copy link
Author

naveedulislam commented Apr 8, 2018

I show the below message:

(C:\Anaconda3) C:\Users\navee>python -c "import subprocess; subprocess.Popen(['yarn --version'], shell=True)"
'"yarn --version"' is not recognized as an internal or external command,
operable program or batch file.

I even tried reinstalling everything and then tried the above command again but no change.

Also tried several differnt options provided in the refrerred post and others but no encouraging output.

@SabarishVT
Copy link

if notebook is None:
            return Popen(command,shell=True, cwd=self._build_dir).wait()
        cmd = Popen(command,shell=True, cwd=self._build_dir, stdout=PIPE, stderr=STDOUT)

I was able to overcome the issue with subprocess.Popen error by modifying the above line of codes in bowtie _app.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted windows Microsoft Windows issues
Projects
None yet
Development

No branches or pull requests

3 participants