PIP3 error

Issue #59 resolved
Randy Hopkins created an issue

Complete novice to Python and Open Source, I am Sys Admin trying to get environment going for Developers. Had everything good but now when i do a “pip3 list” while in QP2TERM I get getting the messages below;

pip3[4]: import: not found.
pip3[5]: import: not found.
pip3[7]: from: not found.
pip3[9]: 0403-057 Syntax error at line 10 : `(' is not expected.
\$

not sure where to go to fix and honestly not sure if i didn’t have someone playing and messed it up. Any ideas will be greatly apprecaited.

Thank you

Comments (6)

  1. Kevin Adler

    It appears that pip3 is being executed by the shell instead of by Python for some reason.

    First, make sure you're getting the yum version of pip3. Make sure the output of which pip3 points to /QOpenSys/pkgs/bin/pip3

    Then, make sure the shebang line is correct for pip3. head -n 1 /QOpenSys/pkgs/bin/pip3 should say /QOpenSys/pkgs/bin/python3

  2. Randy Hopkins reporter

    Thank you for the response, I ran the following commands and please excuse my ignorance on this, I am a systems admin have not worked in this environment at all

    /QOpenSys/usr/bin/-sh        

       $                                                                                
     > which pip3                                                                       
       /QOpenSys/pkgs/bin/pip3                                                          
       $                                                                                
     > head -n 1 /QOpenSys/pkgs/bin/pip3                                                
       #!/QOpenSys/pkgs/bin/python3                                                     
       $                                                                                

    Any feedback is greatly appreciated.

  3. Jesse G

    Did you manually edit /QOpenSys/pkgs/bin/pip3 in any way? The shell, per my understanding, starts by checking the first two bytes of the file for #!. If the file was edited, it’s possible that the editor inserted some unexpected bytes (for instance if it was saved as UTF-16 from a client-side editor or EBCDIC-ized by a green screen editor).

    It might also be interesting to run file /QOpenSys/pkgs/bin/pip3 (the output should be "/QOpenSys/pkgs/bin/pip3: shell script"). If file thinks it’s not a shell script, then it’s time to open it up in a text editor.

    In any event, yum reinstall python3-pip could be your fix (though we’d be missing the excitement of root cause discovery).

  4. Randy Hopkins reporter

    I did not do any edits on any files, I went via the green screen to see if any change is shown and the last data change date/time is 8/08/18 so not sure.

    Ran the command

    > file /QOpenSys/pkgs/bin/pip3              
       /QOpenSys/pkgs/bin/pip3: shell script     
       $                                         

    Well, don’t have the satisfaction of knowing what caused the issue, but following the last comment, did the reinstall of pip, that did not work but did the YUM reinstall of Python3 and seems to have fixed it,

    thank you!

  5. Log in to comment