python3 docopt throws usage error while using pyCharm












3














I need some basic help on docopt with python3.7 .I am using in pyCharm.
I tried to let run the example code which is shown on the docopt.org website. But the system is throwing usage errors.
I installed the doctop through pip install docopt an have version 0.6.2 .
I found a thread with the same error messages, but the user didn't have a docstring in it, so that is why it didn't work for him.



Here is the code:



#!/usr/bin/python
# -*- coding: utf-8 -*-

"""Naval fate.

Usage:
naval_fate.py ship new <name>...
naval_fate.py ship <name> move <x> <y> [ --speed=<kn>]
naval_fate.py ship shoot <x> <y>
naval_fate.py mine (set|remove) <x> <y> [--moored|--drifting}
naval_fate.py -h| --help
naval_fate.py --version

Options:
-h --help Show this screen.
--version Show version.
--speed=<kn> Speed in knots [default: 10].
-- moored Moored (anchored) mine.
-- drifting Drifting mine.

"""
from docopt import docopt

if __name__ == '__main__':
arguments = docopt(__doc__, version='1')
print(arguments)


Here is ther ERROR:



...Scriptspython.exe 
.../naval_fate.py
Traceback (most recent call last):
File
".../naval_fate.py", line 27, in <module>
arguments = docopt(__doc__, version='1')
File "...libsite-packagesdocopt.py", line 558, in docopt
DocoptExit.usage = printable_usage(doc)
File "...libsite-packagesdocopt.py", line 466, in printable_usage
usage_split = re.split(r'([Uu][Ss][Aa][Gg][Ee]:)', doc)
File "C:PythonPython37Libre.py", line 213, in split
return _compile(pattern, flags).split(string, maxsplit)
TypeError: expected string or bytes-like object

Process finished with exit code 1


What I tried:




  • deleted the file extensions of naval_fate.py.

  • uninstalled and reinstalled docopt.

  • changed the positions of the words in and after the usage and options
    sections.

  • used two spaces between the options and the text (as found in another
    thread)

  • tried to format outside the docstring in diffrent ways.


e.g



from docopt
...
arguments = docopt.docopt(__doc__, version='1')


instead of



from docopt import docopt
...
arguments = docopt(__doc__, version='1')


But it all didn't help. Does anybody have an idea?
Thanks so far.










share|improve this question





























    3














    I need some basic help on docopt with python3.7 .I am using in pyCharm.
    I tried to let run the example code which is shown on the docopt.org website. But the system is throwing usage errors.
    I installed the doctop through pip install docopt an have version 0.6.2 .
    I found a thread with the same error messages, but the user didn't have a docstring in it, so that is why it didn't work for him.



    Here is the code:



    #!/usr/bin/python
    # -*- coding: utf-8 -*-

    """Naval fate.

    Usage:
    naval_fate.py ship new <name>...
    naval_fate.py ship <name> move <x> <y> [ --speed=<kn>]
    naval_fate.py ship shoot <x> <y>
    naval_fate.py mine (set|remove) <x> <y> [--moored|--drifting}
    naval_fate.py -h| --help
    naval_fate.py --version

    Options:
    -h --help Show this screen.
    --version Show version.
    --speed=<kn> Speed in knots [default: 10].
    -- moored Moored (anchored) mine.
    -- drifting Drifting mine.

    """
    from docopt import docopt

    if __name__ == '__main__':
    arguments = docopt(__doc__, version='1')
    print(arguments)


    Here is ther ERROR:



    ...Scriptspython.exe 
    .../naval_fate.py
    Traceback (most recent call last):
    File
    ".../naval_fate.py", line 27, in <module>
    arguments = docopt(__doc__, version='1')
    File "...libsite-packagesdocopt.py", line 558, in docopt
    DocoptExit.usage = printable_usage(doc)
    File "...libsite-packagesdocopt.py", line 466, in printable_usage
    usage_split = re.split(r'([Uu][Ss][Aa][Gg][Ee]:)', doc)
    File "C:PythonPython37Libre.py", line 213, in split
    return _compile(pattern, flags).split(string, maxsplit)
    TypeError: expected string or bytes-like object

    Process finished with exit code 1


    What I tried:




    • deleted the file extensions of naval_fate.py.

    • uninstalled and reinstalled docopt.

    • changed the positions of the words in and after the usage and options
      sections.

    • used two spaces between the options and the text (as found in another
      thread)

    • tried to format outside the docstring in diffrent ways.


    e.g



    from docopt
    ...
    arguments = docopt.docopt(__doc__, version='1')


    instead of



    from docopt import docopt
    ...
    arguments = docopt(__doc__, version='1')


    But it all didn't help. Does anybody have an idea?
    Thanks so far.










    share|improve this question



























      3












      3








      3







      I need some basic help on docopt with python3.7 .I am using in pyCharm.
      I tried to let run the example code which is shown on the docopt.org website. But the system is throwing usage errors.
      I installed the doctop through pip install docopt an have version 0.6.2 .
      I found a thread with the same error messages, but the user didn't have a docstring in it, so that is why it didn't work for him.



      Here is the code:



      #!/usr/bin/python
      # -*- coding: utf-8 -*-

      """Naval fate.

      Usage:
      naval_fate.py ship new <name>...
      naval_fate.py ship <name> move <x> <y> [ --speed=<kn>]
      naval_fate.py ship shoot <x> <y>
      naval_fate.py mine (set|remove) <x> <y> [--moored|--drifting}
      naval_fate.py -h| --help
      naval_fate.py --version

      Options:
      -h --help Show this screen.
      --version Show version.
      --speed=<kn> Speed in knots [default: 10].
      -- moored Moored (anchored) mine.
      -- drifting Drifting mine.

      """
      from docopt import docopt

      if __name__ == '__main__':
      arguments = docopt(__doc__, version='1')
      print(arguments)


      Here is ther ERROR:



      ...Scriptspython.exe 
      .../naval_fate.py
      Traceback (most recent call last):
      File
      ".../naval_fate.py", line 27, in <module>
      arguments = docopt(__doc__, version='1')
      File "...libsite-packagesdocopt.py", line 558, in docopt
      DocoptExit.usage = printable_usage(doc)
      File "...libsite-packagesdocopt.py", line 466, in printable_usage
      usage_split = re.split(r'([Uu][Ss][Aa][Gg][Ee]:)', doc)
      File "C:PythonPython37Libre.py", line 213, in split
      return _compile(pattern, flags).split(string, maxsplit)
      TypeError: expected string or bytes-like object

      Process finished with exit code 1


      What I tried:




      • deleted the file extensions of naval_fate.py.

      • uninstalled and reinstalled docopt.

      • changed the positions of the words in and after the usage and options
        sections.

      • used two spaces between the options and the text (as found in another
        thread)

      • tried to format outside the docstring in diffrent ways.


      e.g



      from docopt
      ...
      arguments = docopt.docopt(__doc__, version='1')


      instead of



      from docopt import docopt
      ...
      arguments = docopt(__doc__, version='1')


      But it all didn't help. Does anybody have an idea?
      Thanks so far.










      share|improve this question















      I need some basic help on docopt with python3.7 .I am using in pyCharm.
      I tried to let run the example code which is shown on the docopt.org website. But the system is throwing usage errors.
      I installed the doctop through pip install docopt an have version 0.6.2 .
      I found a thread with the same error messages, but the user didn't have a docstring in it, so that is why it didn't work for him.



      Here is the code:



      #!/usr/bin/python
      # -*- coding: utf-8 -*-

      """Naval fate.

      Usage:
      naval_fate.py ship new <name>...
      naval_fate.py ship <name> move <x> <y> [ --speed=<kn>]
      naval_fate.py ship shoot <x> <y>
      naval_fate.py mine (set|remove) <x> <y> [--moored|--drifting}
      naval_fate.py -h| --help
      naval_fate.py --version

      Options:
      -h --help Show this screen.
      --version Show version.
      --speed=<kn> Speed in knots [default: 10].
      -- moored Moored (anchored) mine.
      -- drifting Drifting mine.

      """
      from docopt import docopt

      if __name__ == '__main__':
      arguments = docopt(__doc__, version='1')
      print(arguments)


      Here is ther ERROR:



      ...Scriptspython.exe 
      .../naval_fate.py
      Traceback (most recent call last):
      File
      ".../naval_fate.py", line 27, in <module>
      arguments = docopt(__doc__, version='1')
      File "...libsite-packagesdocopt.py", line 558, in docopt
      DocoptExit.usage = printable_usage(doc)
      File "...libsite-packagesdocopt.py", line 466, in printable_usage
      usage_split = re.split(r'([Uu][Ss][Aa][Gg][Ee]:)', doc)
      File "C:PythonPython37Libre.py", line 213, in split
      return _compile(pattern, flags).split(string, maxsplit)
      TypeError: expected string or bytes-like object

      Process finished with exit code 1


      What I tried:




      • deleted the file extensions of naval_fate.py.

      • uninstalled and reinstalled docopt.

      • changed the positions of the words in and after the usage and options
        sections.

      • used two spaces between the options and the text (as found in another
        thread)

      • tried to format outside the docstring in diffrent ways.


      e.g



      from docopt
      ...
      arguments = docopt.docopt(__doc__, version='1')


      instead of



      from docopt import docopt
      ...
      arguments = docopt(__doc__, version='1')


      But it all didn't help. Does anybody have an idea?
      Thanks so far.







      pycharm python-3.7 docopt






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 10 at 14:22

























      asked Nov 10 at 13:56









      Dshoon

      163




      163
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Well, I found it! It was the curly braces at the end of the line in the 'Usage' part.



          naval_fate.py  mine (set|remove) <x> <y> [--moored|--drifting}


          After changing it to ] everything worked well.

          Hopefully I can help someone else with this little(big) mistake.






          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239671%2fpython3-docopt-throws-usage-error-while-using-pycharm%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Well, I found it! It was the curly braces at the end of the line in the 'Usage' part.



            naval_fate.py  mine (set|remove) <x> <y> [--moored|--drifting}


            After changing it to ] everything worked well.

            Hopefully I can help someone else with this little(big) mistake.






            share|improve this answer


























              0














              Well, I found it! It was the curly braces at the end of the line in the 'Usage' part.



              naval_fate.py  mine (set|remove) <x> <y> [--moored|--drifting}


              After changing it to ] everything worked well.

              Hopefully I can help someone else with this little(big) mistake.






              share|improve this answer
























                0












                0








                0






                Well, I found it! It was the curly braces at the end of the line in the 'Usage' part.



                naval_fate.py  mine (set|remove) <x> <y> [--moored|--drifting}


                After changing it to ] everything worked well.

                Hopefully I can help someone else with this little(big) mistake.






                share|improve this answer












                Well, I found it! It was the curly braces at the end of the line in the 'Usage' part.



                naval_fate.py  mine (set|remove) <x> <y> [--moored|--drifting}


                After changing it to ] everything worked well.

                Hopefully I can help someone else with this little(big) mistake.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 13 at 9:18









                Dshoon

                163




                163






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239671%2fpython3-docopt-throws-usage-error-while-using-pycharm%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Schultheiß

                    Liste der Kulturdenkmale in Wilsdruff

                    Android Play Services Check