Python-docs-samples: ImportError: No module named sysconfig when installing the dependencies

Created on 21 Dec 2016  路  3Comments  路  Source: GoogleCloudPlatform/python-docs-samples

In which file did you encounter the issue?

https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/speech/grpc/requirements.txt

Did you change the file? If so, how?

No

Describe the issue

Target was to install cloud speech SDK in CentOS 6.6. and run the transcribe_streaming.py sample. Installed python 2.7.12 and OS has 2.6.6.
When I try to install dependencies of cloud speech from requriements.txt, following error is thrown.

bash-4.1$ pip install -r requirements.txt
Downloading/unpacking grpcio==1.0.4 (from -r requirements.txt (line 1))
  Running setup.py egg_info for package grpcio
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "/tmp/pip-build-ck40283/grpcio/setup.py", line 42, in <module>
        import sysconfig
    ImportError: No module named sysconfig
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 16, in <module>
  File "/tmp/pip-build-ck40283/grpcio/setup.py", line 42, in <module>
    import sysconfig
ImportError: No module named sysconfig
----------------------------------------
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-ck40283/grpcio
Storing complete log in /home/ck40283/.pip/pip.log

Error suggests that sysconfig is not available in the python env but the command line doesn't throw an error when it is imported.

bash-4.1$ python 
Python 2.7.12 (default, Dec 20 2016, 18:17:56) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sysconfig
>>> 

When individual modules in requirements.txt is attempted to be installed, only the following module were giving errors. Rest for installed without errors.

grpcio==1.0.4
PyAudio==0.2.9

What could be the reason and how could this be resolved?

Most helpful comment

When I ran into this, it was caused by having /usr/lib/python2.6/site-packages/pkg_resources/ conflicting with /usr/lib/python2.6/site-packages/pkg_resources.py. Erasing the directory allowed everything to work as before. I assume a pip install was the cause, but don't know which package.

All 3 comments

Got it sorted out. It was an issue with python 2.6.6 that I was having. I updated the python to 2.7.12 and used it to create a virtual environment.
bash-4.1$ virtualenv -p python2.7 env

Dependencies got installed correctly except pyaudio. Issue could be due to portaudio not been installed in CentOS. For now, I can live with it as I'm working on using arecord / alsa for streaming audio to cloud speech API. See #728

Yeah - the portaudio dependency is a pain, but necessary for cross-platform device support. Hopefully getting alsa to work will be easier :-)

When I ran into this, it was caused by having /usr/lib/python2.6/site-packages/pkg_resources/ conflicting with /usr/lib/python2.6/site-packages/pkg_resources.py. Erasing the directory allowed everything to work as before. I assume a pip install was the cause, but don't know which package.

Was this page helpful?
0 / 5 - 0 ratings