rizsotto / scan-build

Clang's scan-build re-implementation in python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ImportError: No module named typing

tmsblgh opened this issue · comments

I installed scan build after a clone from git repository and it was successful. But after that I tried to use it and I got an error:

Baloghs-MacBook-Pro:scan-build tamasbalogh$ sudo python ./setup.py install
running install
Checking .pth file support in /Library/Python/2.7/site-packages/
/usr/bin/python -E -c pass
TEST PASSED: /Library/Python/2.7/site-packages/ appears to support .pth files
running bdist_egg
running egg_info
writing scan_build.egg-info/PKG-INFO
writing top-level names to scan_build.egg-info/top_level.txt
writing dependency_links to scan_build.egg-info/dependency_links.txt
writing entry points to scan_build.egg-info/entry_points.txt
reading manifest file 'scan_build.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'scan_build.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.13-intel/egg
running install_lib
running build_py
creating build/bdist.macosx-10.13-intel/egg
creating build/bdist.macosx-10.13-intel/egg/libscanbuild
copying build/lib/libscanbuild/intercept.py -> build/bdist.macosx-10.13-intel/egg/libscanbuild
copying build/lib/libscanbuild/arguments.py -> build/bdist.macosx-10.13-intel/egg/libscanbuild
creating build/bdist.macosx-10.13-intel/egg/libscanbuild/resources
copying build/lib/libscanbuild/resources/sorttable.js -> build/bdist.macosx-10.13-intel/egg/libscanbuild/resources
copying build/lib/libscanbuild/resources/selectable.js -> build/bdist.macosx-10.13-intel/egg/libscanbuild/resources
copying build/lib/libscanbuild/resources/scanview.css -> build/bdist.macosx-10.13-intel/egg/libscanbuild/resources
copying build/lib/libscanbuild/__init__.py -> build/bdist.macosx-10.13-intel/egg/libscanbuild
copying build/lib/libscanbuild/compilation.py -> build/bdist.macosx-10.13-intel/egg/libscanbuild
copying build/lib/libscanbuild/report.py -> build/bdist.macosx-10.13-intel/egg/libscanbuild
copying build/lib/libscanbuild/analyze.py -> build/bdist.macosx-10.13-intel/egg/libscanbuild
copying build/lib/libscanbuild/clang.py -> build/bdist.macosx-10.13-intel/egg/libscanbuild
creating build/bdist.macosx-10.13-intel/egg/libear
copying build/lib/libear/config.h.in -> build/bdist.macosx-10.13-intel/egg/libear
copying build/lib/libear/__init__.py -> build/bdist.macosx-10.13-intel/egg/libear
copying build/lib/libear/ear.c -> build/bdist.macosx-10.13-intel/egg/libear
byte-compiling build/bdist.macosx-10.13-intel/egg/libscanbuild/intercept.py to intercept.pyc
byte-compiling build/bdist.macosx-10.13-intel/egg/libscanbuild/arguments.py to arguments.pyc
byte-compiling build/bdist.macosx-10.13-intel/egg/libscanbuild/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.13-intel/egg/libscanbuild/compilation.py to compilation.pyc
byte-compiling build/bdist.macosx-10.13-intel/egg/libscanbuild/report.py to report.pyc
byte-compiling build/bdist.macosx-10.13-intel/egg/libscanbuild/analyze.py to analyze.pyc
byte-compiling build/bdist.macosx-10.13-intel/egg/libscanbuild/clang.py to clang.pyc
byte-compiling build/bdist.macosx-10.13-intel/egg/libear/__init__.py to __init__.pyc
creating build/bdist.macosx-10.13-intel/egg/EGG-INFO
copying scan_build.egg-info/PKG-INFO -> build/bdist.macosx-10.13-intel/egg/EGG-INFO
copying scan_build.egg-info/SOURCES.txt -> build/bdist.macosx-10.13-intel/egg/EGG-INFO
copying scan_build.egg-info/dependency_links.txt -> build/bdist.macosx-10.13-intel/egg/EGG-INFO
copying scan_build.egg-info/entry_points.txt -> build/bdist.macosx-10.13-intel/egg/EGG-INFO
copying scan_build.egg-info/not-zip-safe -> build/bdist.macosx-10.13-intel/egg/EGG-INFO
copying scan_build.egg-info/top_level.txt -> build/bdist.macosx-10.13-intel/egg/EGG-INFO
creating 'dist/scan_build-2.0.9-py2.7.egg' and adding 'build/bdist.macosx-10.13-intel/egg' to it
removing 'build/bdist.macosx-10.13-intel/egg' (and everything under it)
Processing scan_build-2.0.9-py2.7.egg
removing '/Library/Python/2.7/site-packages/scan_build-2.0.9-py2.7.egg' (and everything under it)
creating /Library/Python/2.7/site-packages/scan_build-2.0.9-py2.7.egg
Extracting scan_build-2.0.9-py2.7.egg to /Library/Python/2.7/site-packages
scan-build 2.0.9 is already the active version in easy-install.pth
Installing analyze-build script to /usr/local/bin
Installing analyze-cc script to /usr/local/bin
Installing intercept-cc script to /usr/local/bin
Installing intercept-build script to /usr/local/bin
Installing intercept-c++ script to /usr/local/bin
Installing analyze-c++ script to /usr/local/bin
Installing scan-build script to /usr/local/bin

Installed /Library/Python/2.7/site-packages/scan_build-2.0.9-py2.7.egg
Processing dependencies for scan-build==2.0.9
Finished processing dependencies for scan-build==2.0.9

Baloghs-MacBook-Pro:scan-build tamasbalogh$ python --version
Python 2.7.10

Baloghs-MacBook-Pro:scan-build tamasbalogh$ intercept-build 
Traceback (most recent call last):
  File "/usr/local/bin/intercept-build", line 9, in <module>
    load_entry_point('scan-build==2.0.9', 'console_scripts', 'intercept-build')()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 565, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2697, in load_entry_point
    return ep.load()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2370, in load
    return self.resolve()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2376, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/Library/Python/2.7/site-packages/scan_build-2.0.9-py2.7.egg/libscanbuild/__init__.py", line 18, in <module>
    from typing import List, Any, Dict, Callable  # noqa: ignore=F401
ImportError: No module named typing

What can be the problem?

System information: MacOS 10.13

Thanks for the report. I presume you were not install the dependencies of scan-build package. (That's what the error is about.) I would recommend to install it as it suggested in the readme file, since pip will ensure that dependencies are satisfied. (I would also suggest to use virtualenv or virtualenvwrapper instead of sudo install any software on you machine.)

I tried like as your wrote:

Baloghs-MacBook-Pro:scan-build tamasbalogh$ make intercept_build_venv
# Create a virtual environment which can be used to run the build package.
virtualenv -p python2 intercept_build && \
		. intercept_build/bin/activate && pip install -r ./req
Running virtualenv with interpreter /usr/local/bin/python2
New python executable in /Users/tamasbalogh/scan-build/intercept_build/bin/python2.7
Also creating executable in /Users/tamasbalogh/scan-build/intercept_build/bin/python
Installing setuptools, pip, wheel...done.
Collecting scan-build (from -r ./req (line 1))
Installing collected packages: scan-build
Successfully installed scan-build-2.0.9
Baloghs-MacBook-Pro:scan-build tamasbalogh$ source /Users/tamasbalogh/scan-build/intercept_build/bin/activate
(intercept_build) Baloghs-MacBook-Pro:scan-build tamasbalogh$ intercept-build 
Traceback (most recent call last):
  File "/Users/tamasbalogh/scan-build/intercept_build/bin/intercept-build", line 7, in <module>
    from libscanbuild.intercept import intercept_build
  File "/Users/tamasbalogh/scan-build/intercept_build/lib/python2.7/site-packages/libscanbuild/__init__.py", line 18, in <module>
    from typing import List, Any, Dict, Callable  # noqa: ignore=F401
ImportError: No module named typing

You are right, the dependency was not defined in the setup.py. Fixed , now version 2.0.10 works as simple as pip install scan-build.

For python3, it seems that typing is just a blank module that is left only for backwards compatibility and it's functionality is provided as part of the stdlib. Source: https://pypi.org/project/typing/

I've encountered this issue after packaging for Arch Linux while python-typing doesn't exist in the packages official repositories.

I think you should add a condition that will import the relevant stuff List, Any, Dict, Callable only when running with a python2 interpreter. Installing typing should be discouraged. This should be reopened.

Thanks for the update. Will work on it soon.

Fixed in version 2.0.14