Community
    • Login

    Notepad++/Visual Studio 2019/Python

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    6 Posts 4 Posters 1.0k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Mark HanleyM
      Mark Hanley
      last edited by Mark Hanley

      I am trying to get NPP to execute python and run a script that I am editing from run menu. I am using the command line

      C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\python “$(FULL_CURRENT_PATH)”

      Which stops with an error code of 2. But, if I use nppexec and use the command line

      cd C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64
      python “$(FULL_CURRENT_PATH)”

      it works. ANy ideas as to why the single line command fails, but the 2 line command works?

      Thanks

      1 Reply Last reply Reply Quote 0
      • Michael VincentM
        Michael Vincent
        last edited by

        By “Error code 2” I assume you mean N++ is popping a window with that error code? If that’s the case, it’s explaining that it can’t find the command “C:\Program” and the rest as the arguments since there’s a space.

        Try wrapping the python command in double quotes in your Run menu config in shortcuts.xml:

                <Command name="Run Python" Ctrl="no" Alt="no" Shift="no" Key="0">"C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\python" $(FULL_CURRENT_PATH)</Command>
        

        Interestingly, NppExec doesn’t need quotes around the path even with spaces.

        Cheers.

        1 Reply Last reply Reply Quote 4
        • Steven HaymesS
          Steven Haymes
          last edited by Steven Haymes

          Mark,

          “C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\python” “$(FULL_CURRENT_PATH)” should fix the problem. When you cd to the Visual Studio installation directory for Python, the spaces in the path are no longer an issue as you are in the same directory as the Python executable.

          Personally, I would not have Visual Studio install Python and instead use the Python installer. The Visual Studio installer (I am still on Visual Studio 2017), will allow you to install Python support without installing Python. I have the following Python installations on my computers:

          • C:\Python27 - for legacy programs
          • C:\Python37 - for current programs

          For many years at work, my main software used Python 2.N and had the option to not install it because I already had it installed under C:\Python27. I have NppExec set up to run Python scripts (with arguments) and to also run the Python debuggers/linters Pylint and Flake8.

          Steve

          Alan KilbornA 1 Reply Last reply Reply Quote 1
          • Alan KilbornA
            Alan Kilborn @Steven Haymes
            last edited by

            @Steven-Haymes said:

            “C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\python” “$(FULL_CURRENT_PATH)”

            It seems like this should be better than Michael’s suggestion in the event that there are any spaces in $(FULL_CURRENT_PATH). Michael left wrapping double quotes out of that, even though the OP had them there in 2 places. Interesting. :)

            When you cd to the Visual Studio installation directory for Python, the spaces in the path are no longer an issue

            Not sure I’m following this part as the OP was only doing the cd for purposes of trying an equivalent thing with NppExec. There should be no cd in what the OP is finally trying to get to?

            Steven HaymesS 1 Reply Last reply Reply Quote 2
            • Steven HaymesS
              Steven Haymes @Alan Kilborn
              last edited by

              @Alan-Kilborn

              I agree that there should be no cd. I was not thinking about how NppExec works when I mentioned about cd’ing to the directory where the Python executable is located. I was thinking more about how the Windows command prompt works. Maybe, I should have been thinking about NppExec? IMHO, spaces in file and directory names was never a good idea.

              S

              1 Reply Last reply Reply Quote 1
              • Michael VincentM
                Michael Vincent
                last edited by Michael Vincent

                @Alan-Kilborn said:

                Michael left wrapping double quotes out of that, even though the OP had them there in 2 places

                purely an oversight - thanks. Corrected below:

                    <Command name="Run Python" Ctrl="no" Alt="no" Shift="no" Key="0">"C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\python" "$(FULL_CURRENT_PATH)"</Command>
                
                1 Reply Last reply Reply Quote 3
                • First post
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors