Cygwin paths for Windows python












3















I have access to a machine with a minimal cygwin installation, and the Windows version of python. I need to run some python scripts there, however python requires Windows paths. I can use cygpath -w, on the arguments that I provide, however further unix/cygwin paths are included in numerous other scripts which are subsequently invoked.



Is there a way to tell Windows python to accept unix/cygwin paths?










share|improve this question



























    3















    I have access to a machine with a minimal cygwin installation, and the Windows version of python. I need to run some python scripts there, however python requires Windows paths. I can use cygpath -w, on the arguments that I provide, however further unix/cygwin paths are included in numerous other scripts which are subsequently invoked.



    Is there a way to tell Windows python to accept unix/cygwin paths?










    share|improve this question

























      3












      3








      3








      I have access to a machine with a minimal cygwin installation, and the Windows version of python. I need to run some python scripts there, however python requires Windows paths. I can use cygpath -w, on the arguments that I provide, however further unix/cygwin paths are included in numerous other scripts which are subsequently invoked.



      Is there a way to tell Windows python to accept unix/cygwin paths?










      share|improve this question














      I have access to a machine with a minimal cygwin installation, and the Windows version of python. I need to run some python scripts there, however python requires Windows paths. I can use cygpath -w, on the arguments that I provide, however further unix/cygwin paths are included in numerous other scripts which are subsequently invoked.



      Is there a way to tell Windows python to accept unix/cygwin paths?







      python cygwin






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 10 '11 at 11:43









      user2023370user2023370

      4,53823163




      4,53823163
























          2 Answers
          2






          active

          oldest

          votes


















          1














          Create a file named wpython and save it somewhere for example in /bin:



          #!/bin/bash

          path=$1
          shift # Remove filepath from other args to pass them further
          python.exe $(cygpath -w $path) $@ # Call python.exe with Windows path and passed args


          So then use it like this:



          #!/usr/bin/env wpython
          print(123)


          Don't forget to make both file executable with: chmod +x filename



          P.S.: Soultion based on this blog post.






          share|improve this answer































            3














            No, Windows python has no suport for Cygwin paths, but Cygwin does have its own Python. If you can't add that to the existing Cygwin install, you might want to consider doing a user-specific Cygwin install into a directory that you're allowed to write to.



            There is a way to obtain limited Cygwin path support for Windows programs, although I suspect this isn't an option for you either: install Cygwin into C:, so that a Cygwin /path is equivalent to C:path. This relies on the fact that the Windows API (albeit not all Windows programs) accepts both backslashes and slashes as path separators, and that it considers absolute paths without drive letter as referring to the system drive (i.e. C:).



            Obviously this won't work for Cygwin paths that point to other drives (via the Cygwin mount table). It also won't work for any programs that use / (rather than -) to introduce options, which includes most built-in Windows command-line tools. But it does usually work for cross-platform tools such as Python.



            Yet another option is to use MSYS instead of Cygwin, which is a fork of an old Cygwin version, whereby its most distinctive feature is that it automatically translates POSIX paths to Windows paths when invoking Windows programs. Note however, that this approach has its pitfalls too, because it isn't always clear whether an argument is a path or not. Hence, sometimes it will fail to translate a path or wrongly change an argument that isn't a path.






            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%2f8078967%2fcygwin-paths-for-windows-python%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














              Create a file named wpython and save it somewhere for example in /bin:



              #!/bin/bash

              path=$1
              shift # Remove filepath from other args to pass them further
              python.exe $(cygpath -w $path) $@ # Call python.exe with Windows path and passed args


              So then use it like this:



              #!/usr/bin/env wpython
              print(123)


              Don't forget to make both file executable with: chmod +x filename



              P.S.: Soultion based on this blog post.






              share|improve this answer




























                1














                Create a file named wpython and save it somewhere for example in /bin:



                #!/bin/bash

                path=$1
                shift # Remove filepath from other args to pass them further
                python.exe $(cygpath -w $path) $@ # Call python.exe with Windows path and passed args


                So then use it like this:



                #!/usr/bin/env wpython
                print(123)


                Don't forget to make both file executable with: chmod +x filename



                P.S.: Soultion based on this blog post.






                share|improve this answer


























                  1












                  1








                  1







                  Create a file named wpython and save it somewhere for example in /bin:



                  #!/bin/bash

                  path=$1
                  shift # Remove filepath from other args to pass them further
                  python.exe $(cygpath -w $path) $@ # Call python.exe with Windows path and passed args


                  So then use it like this:



                  #!/usr/bin/env wpython
                  print(123)


                  Don't forget to make both file executable with: chmod +x filename



                  P.S.: Soultion based on this blog post.






                  share|improve this answer













                  Create a file named wpython and save it somewhere for example in /bin:



                  #!/bin/bash

                  path=$1
                  shift # Remove filepath from other args to pass them further
                  python.exe $(cygpath -w $path) $@ # Call python.exe with Windows path and passed args


                  So then use it like this:



                  #!/usr/bin/env wpython
                  print(123)


                  Don't forget to make both file executable with: chmod +x filename



                  P.S.: Soultion based on this blog post.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 21 '18 at 21:36









                  Саша КошкинСаша Кошкин

                  563




                  563

























                      3














                      No, Windows python has no suport for Cygwin paths, but Cygwin does have its own Python. If you can't add that to the existing Cygwin install, you might want to consider doing a user-specific Cygwin install into a directory that you're allowed to write to.



                      There is a way to obtain limited Cygwin path support for Windows programs, although I suspect this isn't an option for you either: install Cygwin into C:, so that a Cygwin /path is equivalent to C:path. This relies on the fact that the Windows API (albeit not all Windows programs) accepts both backslashes and slashes as path separators, and that it considers absolute paths without drive letter as referring to the system drive (i.e. C:).



                      Obviously this won't work for Cygwin paths that point to other drives (via the Cygwin mount table). It also won't work for any programs that use / (rather than -) to introduce options, which includes most built-in Windows command-line tools. But it does usually work for cross-platform tools such as Python.



                      Yet another option is to use MSYS instead of Cygwin, which is a fork of an old Cygwin version, whereby its most distinctive feature is that it automatically translates POSIX paths to Windows paths when invoking Windows programs. Note however, that this approach has its pitfalls too, because it isn't always clear whether an argument is a path or not. Hence, sometimes it will fail to translate a path or wrongly change an argument that isn't a path.






                      share|improve this answer






























                        3














                        No, Windows python has no suport for Cygwin paths, but Cygwin does have its own Python. If you can't add that to the existing Cygwin install, you might want to consider doing a user-specific Cygwin install into a directory that you're allowed to write to.



                        There is a way to obtain limited Cygwin path support for Windows programs, although I suspect this isn't an option for you either: install Cygwin into C:, so that a Cygwin /path is equivalent to C:path. This relies on the fact that the Windows API (albeit not all Windows programs) accepts both backslashes and slashes as path separators, and that it considers absolute paths without drive letter as referring to the system drive (i.e. C:).



                        Obviously this won't work for Cygwin paths that point to other drives (via the Cygwin mount table). It also won't work for any programs that use / (rather than -) to introduce options, which includes most built-in Windows command-line tools. But it does usually work for cross-platform tools such as Python.



                        Yet another option is to use MSYS instead of Cygwin, which is a fork of an old Cygwin version, whereby its most distinctive feature is that it automatically translates POSIX paths to Windows paths when invoking Windows programs. Note however, that this approach has its pitfalls too, because it isn't always clear whether an argument is a path or not. Hence, sometimes it will fail to translate a path or wrongly change an argument that isn't a path.






                        share|improve this answer




























                          3












                          3








                          3







                          No, Windows python has no suport for Cygwin paths, but Cygwin does have its own Python. If you can't add that to the existing Cygwin install, you might want to consider doing a user-specific Cygwin install into a directory that you're allowed to write to.



                          There is a way to obtain limited Cygwin path support for Windows programs, although I suspect this isn't an option for you either: install Cygwin into C:, so that a Cygwin /path is equivalent to C:path. This relies on the fact that the Windows API (albeit not all Windows programs) accepts both backslashes and slashes as path separators, and that it considers absolute paths without drive letter as referring to the system drive (i.e. C:).



                          Obviously this won't work for Cygwin paths that point to other drives (via the Cygwin mount table). It also won't work for any programs that use / (rather than -) to introduce options, which includes most built-in Windows command-line tools. But it does usually work for cross-platform tools such as Python.



                          Yet another option is to use MSYS instead of Cygwin, which is a fork of an old Cygwin version, whereby its most distinctive feature is that it automatically translates POSIX paths to Windows paths when invoking Windows programs. Note however, that this approach has its pitfalls too, because it isn't always clear whether an argument is a path or not. Hence, sometimes it will fail to translate a path or wrongly change an argument that isn't a path.






                          share|improve this answer















                          No, Windows python has no suport for Cygwin paths, but Cygwin does have its own Python. If you can't add that to the existing Cygwin install, you might want to consider doing a user-specific Cygwin install into a directory that you're allowed to write to.



                          There is a way to obtain limited Cygwin path support for Windows programs, although I suspect this isn't an option for you either: install Cygwin into C:, so that a Cygwin /path is equivalent to C:path. This relies on the fact that the Windows API (albeit not all Windows programs) accepts both backslashes and slashes as path separators, and that it considers absolute paths without drive letter as referring to the system drive (i.e. C:).



                          Obviously this won't work for Cygwin paths that point to other drives (via the Cygwin mount table). It also won't work for any programs that use / (rather than -) to introduce options, which includes most built-in Windows command-line tools. But it does usually work for cross-platform tools such as Python.



                          Yet another option is to use MSYS instead of Cygwin, which is a fork of an old Cygwin version, whereby its most distinctive feature is that it automatically translates POSIX paths to Windows paths when invoking Windows programs. Note however, that this approach has its pitfalls too, because it isn't always clear whether an argument is a path or not. Hence, sometimes it will fail to translate a path or wrongly change an argument that isn't a path.







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Nov 10 '11 at 16:07

























                          answered Nov 10 '11 at 15:53









                          ak2ak2

                          5,8362523




                          5,8362523






























                              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.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f8078967%2fcygwin-paths-for-windows-python%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

                              MongoDB - Not Authorized To Execute Command

                              How to fix TextFormField cause rebuild widget in Flutter

                              Npm cannot find a required file even through it is in the searched directory