Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation with pip in Python 3.9 - cppcheck_junit is not recognized as an internal or external command, operable program or batch file #14

Closed
ncook-hxgn opened this issue Jan 13, 2021 · 4 comments
Labels

Comments

@ncook-hxgn
Copy link

ncook-hxgn commented Jan 13, 2021

Following on from #13 ..

I uninstalled cppcheck_junit from Python 2.7's pip, fixed my path to shuffle python versions, and reinstalled into Python 3.9's pip.

I now cannot run cppcheck_junit from the commandline.

The following output is from after some trouble shooting.. hence the "cppcheck_junit is already installed to Python 3.9" message:

E:\repos\Project>python --version
Python 3.9.0

E:\repos\Project>pip install cppcheck_junit --user
Requirement already satisfied: cppcheck_junit in c:\python39\lib\site-packages (2.1.0)
Requirement already satisfied: exitstatus>=1.0.0 in c:\python39\lib\site-packages (from cppcheck_junit) (2.1.0)
WARNING: You are using pip version 20.2.3; however, version 20.3.3 is available.
You should consider upgrading via the 'c:\python39\python.exe -m pip install --upgrade pip' command.

E:\repos\Project>cppcheck_junit cppcheck-result.xml cppcheck-junit.xml
'cppcheck_junit' is not recognized as an internal or external command,
operable program or batch file.

E:\repos\Project>

Please advise any trouble shooting steps I can take.

@ncook-hxgn
Copy link
Author

ncook-hxgn commented Jan 13, 2021

Further, I see the python file, but no .bat or .cmd wrapper. Possibly this is just a documentation issue..

C:\>where /R C:\python39 cppcheck_junit
C:\Python39\Lib\site-packages\cppcheck_junit.py

C:\>

Indeed, using the full path to cppcheck_junit.py works - 🥳 - but this is a little unwieldy. Possibly pip should have put site-packages on the path. Is this a pip bug/config error?

E:\repos\Project>python C:\Python39\Lib\site-packages\cppcheck_junit.py cppcheck-results-all.xml cppcheck-junit.xml

E:\repos\Project>dir *.xml
 Volume in drive E is Data
 Volume Serial Number is CCA5-58EE

 Directory of E:\repos\Project

13/01/2021  17:22            74,299 cppcheck-junit.xml
13/01/2021  16:55           227,275 cppcheck-results-all.xml
               2 File(s)        301,574 bytes
               0 Dir(s)  716,797,235,200 bytes free

E:\repos\Project>

@johnthagen
Copy link
Owner

johnthagen commented Jan 15, 2021

Edit: I am using the global py launcher that is installed by default on Windows. It is a convenient way to use multiple Python versions without having to worry about which program is python in the path: https://www.python.org/dev/peps/pep-0397/. If python is correctly pointing to Python 3, you could also run python -m venv venv as the first step below.

@ncook-hxgn cppcheck_junit uses setuptools to install a console entry point into the Python environment in which it is installed. I think perhaps that the way you installed it on Windows with --user perhaps didn't get it into Windows PATH. I've not tried installing this globally on Windows before like this.

A good practice is to use virtual environments: https://docs.python.org/3/tutorial/venv.html

Please try this:

> py -m venv venv
> venv\Scripts\activate
(venv) > python -m pip install --upgrade pip
(venv) > python -m pip install cppcheck_junit
(venv) > cppcheck_junit --help
usage: cppcheck_junit [-h] input_file output_file

Converts Cppcheck XML version 2 to JUnit XML format.
Usage:
	$ cppcheck --xml-version=2 --enable=all . 2> cppcheck-result.xml
	$ cppcheck_junit cppcheck-result.xml cppcheck-junit.xml

positional arguments:
  input_file   Cppcheck XML version 2 stderr file.
  output_file  JUnit XML output file.

optional arguments:
  -h, --help   show this help message and exit

Whenever you have that venv virtual environment activated the cppcheck_junit tool will be in the PATH. This also keeps cppcheck_junit isolated from other tools you may want to install in the future.

@ncook-hxgn
Copy link
Author

New machine: installed Visual Studio's Python 3.9 and no other pythons. No Pip. (╯°□°)╯︵ ┻━┻

OK I guess I will install Python like a normal person 😁

@ncook-hxgn
Copy link
Author

@johnthagen it works perfectly when installed from 3.9's pip, when there's no cruft from a previous attempt in Python 2.x.

I will look into venv, I think it will probably save us a lot of headaches. I've avoided it for now because there's not a great need for it my this particular case, but it's something I think I need to know about and I can see how it would save me some hassle in the future - thank you for enlightening me to that :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants