Readline for Python 3.6 on Mac 10.14












1















I have Python 3.6.5 on Mac 10.14.
In the Python interpreter, editing/navigation shortcuts (such as arrows, ^e, ^a, etc.) do not work, instead giving me escape chars, e.g.:






Python 3.6.5 (default, Jun 17 2018, 12:13:06)



[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin



Type "help", "copyright", "credits" or "license" for more information.



import blah ^[[A^[[C^[[D^A^E






pip refuses to install readline giving a weird error; I installed gnureadline: it works but ONLY if I explicitly do:





import gnureadline





as a first command in the interpreter.
Which is very ugly.



Is there a better way?










share|improve this question





























    1















    I have Python 3.6.5 on Mac 10.14.
    In the Python interpreter, editing/navigation shortcuts (such as arrows, ^e, ^a, etc.) do not work, instead giving me escape chars, e.g.:






    Python 3.6.5 (default, Jun 17 2018, 12:13:06)



    [GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin



    Type "help", "copyright", "credits" or "license" for more information.



    import blah ^[[A^[[C^[[D^A^E






    pip refuses to install readline giving a weird error; I installed gnureadline: it works but ONLY if I explicitly do:





    import gnureadline





    as a first command in the interpreter.
    Which is very ugly.



    Is there a better way?










    share|improve this question



























      1












      1








      1








      I have Python 3.6.5 on Mac 10.14.
      In the Python interpreter, editing/navigation shortcuts (such as arrows, ^e, ^a, etc.) do not work, instead giving me escape chars, e.g.:






      Python 3.6.5 (default, Jun 17 2018, 12:13:06)



      [GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin



      Type "help", "copyright", "credits" or "license" for more information.



      import blah ^[[A^[[C^[[D^A^E






      pip refuses to install readline giving a weird error; I installed gnureadline: it works but ONLY if I explicitly do:





      import gnureadline





      as a first command in the interpreter.
      Which is very ugly.



      Is there a better way?










      share|improve this question
















      I have Python 3.6.5 on Mac 10.14.
      In the Python interpreter, editing/navigation shortcuts (such as arrows, ^e, ^a, etc.) do not work, instead giving me escape chars, e.g.:






      Python 3.6.5 (default, Jun 17 2018, 12:13:06)



      [GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin



      Type "help", "copyright", "credits" or "license" for more information.



      import blah ^[[A^[[C^[[D^A^E






      pip refuses to install readline giving a weird error; I installed gnureadline: it works but ONLY if I explicitly do:





      import gnureadline





      as a first command in the interpreter.
      Which is very ugly.



      Is there a better way?







      python3 readline






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 12 at 16:59









      Anaksunaman

      5,52321322




      5,52321322










      asked Feb 12 at 5:44









      VK18VK18

      61




      61






















          1 Answer
          1






          active

          oldest

          votes


















          0














          You can make use of the PYTHONSTARTUP environment variable to point to a dotfile that imports the library. This env var is only used for running the interactive prompt and doesn't affect your other projects.



          You'll first need to create that environment variable if you don't have it already. You should be able to do this with the export command, which modifies your current shell environment. To make sure your shell environment always knows about this new environment variable, you'll need to include your export statement in either your ~/.bash_profile, ~/.bashrc, ~/.profile, or other shell configuration file found in your home directory. If you're not aware of how to find those, run the command ls -a ~ (that's a tidle). To search your home directory. Once you find the right file, add this to the bottom:



          export PYTHONSTARTUP=/Users/yourusername/.pythonstartup



          Once you've saved that in the file, you'll now create the startup file where you can include your import statement. As referenced above, this goes in your home directory under the name .pythonstartup. Within that file include your import statement:



          import gnureadline



          You may also wish to include a print function just to let yourself know that you're always importing gnureadline in the interactive prompt:



          print("gnureadline imported via .pythonstartup file in home dir")



          You should open a new terminal tab or new terminal instance once this is all finished. Then start up your python interpreter and you should see the above message and be able to use your library and the shortcuts it affords.






          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "3"
            };
            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%2fsuperuser.com%2fquestions%2f1404715%2freadline-for-python-3-6-on-mac-10-14%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














            You can make use of the PYTHONSTARTUP environment variable to point to a dotfile that imports the library. This env var is only used for running the interactive prompt and doesn't affect your other projects.



            You'll first need to create that environment variable if you don't have it already. You should be able to do this with the export command, which modifies your current shell environment. To make sure your shell environment always knows about this new environment variable, you'll need to include your export statement in either your ~/.bash_profile, ~/.bashrc, ~/.profile, or other shell configuration file found in your home directory. If you're not aware of how to find those, run the command ls -a ~ (that's a tidle). To search your home directory. Once you find the right file, add this to the bottom:



            export PYTHONSTARTUP=/Users/yourusername/.pythonstartup



            Once you've saved that in the file, you'll now create the startup file where you can include your import statement. As referenced above, this goes in your home directory under the name .pythonstartup. Within that file include your import statement:



            import gnureadline



            You may also wish to include a print function just to let yourself know that you're always importing gnureadline in the interactive prompt:



            print("gnureadline imported via .pythonstartup file in home dir")



            You should open a new terminal tab or new terminal instance once this is all finished. Then start up your python interpreter and you should see the above message and be able to use your library and the shortcuts it affords.






            share|improve this answer




























              0














              You can make use of the PYTHONSTARTUP environment variable to point to a dotfile that imports the library. This env var is only used for running the interactive prompt and doesn't affect your other projects.



              You'll first need to create that environment variable if you don't have it already. You should be able to do this with the export command, which modifies your current shell environment. To make sure your shell environment always knows about this new environment variable, you'll need to include your export statement in either your ~/.bash_profile, ~/.bashrc, ~/.profile, or other shell configuration file found in your home directory. If you're not aware of how to find those, run the command ls -a ~ (that's a tidle). To search your home directory. Once you find the right file, add this to the bottom:



              export PYTHONSTARTUP=/Users/yourusername/.pythonstartup



              Once you've saved that in the file, you'll now create the startup file where you can include your import statement. As referenced above, this goes in your home directory under the name .pythonstartup. Within that file include your import statement:



              import gnureadline



              You may also wish to include a print function just to let yourself know that you're always importing gnureadline in the interactive prompt:



              print("gnureadline imported via .pythonstartup file in home dir")



              You should open a new terminal tab or new terminal instance once this is all finished. Then start up your python interpreter and you should see the above message and be able to use your library and the shortcuts it affords.






              share|improve this answer


























                0












                0








                0







                You can make use of the PYTHONSTARTUP environment variable to point to a dotfile that imports the library. This env var is only used for running the interactive prompt and doesn't affect your other projects.



                You'll first need to create that environment variable if you don't have it already. You should be able to do this with the export command, which modifies your current shell environment. To make sure your shell environment always knows about this new environment variable, you'll need to include your export statement in either your ~/.bash_profile, ~/.bashrc, ~/.profile, or other shell configuration file found in your home directory. If you're not aware of how to find those, run the command ls -a ~ (that's a tidle). To search your home directory. Once you find the right file, add this to the bottom:



                export PYTHONSTARTUP=/Users/yourusername/.pythonstartup



                Once you've saved that in the file, you'll now create the startup file where you can include your import statement. As referenced above, this goes in your home directory under the name .pythonstartup. Within that file include your import statement:



                import gnureadline



                You may also wish to include a print function just to let yourself know that you're always importing gnureadline in the interactive prompt:



                print("gnureadline imported via .pythonstartup file in home dir")



                You should open a new terminal tab or new terminal instance once this is all finished. Then start up your python interpreter and you should see the above message and be able to use your library and the shortcuts it affords.






                share|improve this answer













                You can make use of the PYTHONSTARTUP environment variable to point to a dotfile that imports the library. This env var is only used for running the interactive prompt and doesn't affect your other projects.



                You'll first need to create that environment variable if you don't have it already. You should be able to do this with the export command, which modifies your current shell environment. To make sure your shell environment always knows about this new environment variable, you'll need to include your export statement in either your ~/.bash_profile, ~/.bashrc, ~/.profile, or other shell configuration file found in your home directory. If you're not aware of how to find those, run the command ls -a ~ (that's a tidle). To search your home directory. Once you find the right file, add this to the bottom:



                export PYTHONSTARTUP=/Users/yourusername/.pythonstartup



                Once you've saved that in the file, you'll now create the startup file where you can include your import statement. As referenced above, this goes in your home directory under the name .pythonstartup. Within that file include your import statement:



                import gnureadline



                You may also wish to include a print function just to let yourself know that you're always importing gnureadline in the interactive prompt:



                print("gnureadline imported via .pythonstartup file in home dir")



                You should open a new terminal tab or new terminal instance once this is all finished. Then start up your python interpreter and you should see the above message and be able to use your library and the shortcuts it affords.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 12 at 18:23









                baelxbaelx

                1,438616




                1,438616






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Super User!


                    • 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%2fsuperuser.com%2fquestions%2f1404715%2freadline-for-python-3-6-on-mac-10-14%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

                    Probability when a professor distributes a quiz and homework assignment to a class of n students.

                    Aardman Animations

                    Are they similar matrix