E: Unable to locate package cmake

I’m trying to deploy the app using streamlit sharing and the error logged on the main screen is:

ModuleNotFoundError: No module named 'dlib'

The error logged in the terminal is as follows:

Building wheels for collected packages: dlib, netifaces
Building wheel for dlib (setup.py): started
Building wheel for dlib (setup.py): finished with status 'error'
ERROR: Command errored out with exit status 1:
   command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-kzxfscb_/dlib_2d582b7043ea4ef1b1e78f4f3909c733/setup.py'"'"'; __file__='"'"'/tmp/pip-install-kzxfscb_/dlib_2d582b7043ea4ef1b1e78f4f3909c733/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-7dy9sm5e
       cwd: /tmp/pip-install-kzxfscb_/dlib_2d582b7043ea4ef1b1e78f4f3909c733/
  Complete output (53 lines):
  running bdist_wheel
  running build
  running build_py
  package init file 'tools/python/dlib/__init__.py' not found (or not a regular file)
  running build_ext
  Traceback (most recent call last):
    File "/tmp/pip-install-kzxfscb_/dlib_2d582b7043ea4ef1b1e78f4f3909c733/setup.py", line 120, in get_cmake_version
      out = subprocess.check_output(['cmake', '--version'])
    File "/usr/local/lib/python3.7/subprocess.py", line 411, in check_output
    File "/usr/local/lib/python3.7/subprocess.py", line 488, in run
      with Popen(*popenargs, **kwargs) as process:
    File "/usr/local/lib/python3.7/subprocess.py", line 800, in __init__
      restore_signals, start_new_session)

    File "/usr/local/lib/python3.7/subprocess.py", line 1551, in _execute_child
      raise child_exception_type(errno_num, err_msg, err_filename)
  FileNotFoundError: [Errno 2] No such file or directory: 'cmake': 'cmake'
  During handling of the above exception, another exception occurred:
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-kzxfscb_/dlib_2d582b7043ea4ef1b1e78f4f3909c733/setup.py", line 262, in <module>
      'Topic :: Software Development',
    File "/usr/local/lib/python3.7/site-packages/setuptools/__init__.py", line 153, in setup
      return distutils.core.setup(**attrs)
    File "/usr/local/lib/python3.7/distutils/core.py", line 148, in setup
    File "/usr/local/lib/python3.7/distutils/dist.py", line 966, in run_commands
    File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
    File "/usr/local/lib/python3.7/site-packages/wheel/bdist_wheel.py", line 299, in run
    File "/usr/local/lib/python3.7/distutils/cmd.py", line 313, in run_command
    File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
    File "/usr/local/lib/python3.7/distutils/command/build.py", line 135, in run
    File "/usr/local/lib/python3.7/distutils/cmd.py", line 313, in run_command
    File "/usr/local/lib/python3.7/distutils/dist.py", line 985, in run_command
    File "/tmp/pip-install-kzxfscb_/dlib_2d582b7043ea4ef1b1e78f4f3909c733/setup.py", line 129, in run
      cmake_version = self.get_cmake_version()
    File "/tmp/pip-install-kzxfscb_/dlib_2d582b7043ea4ef1b1e78f4f3909c733/setup.py", line 125, in get_cmake_version

   CMake must be installed to build the following extensions: _dlib_pybind11

It looks like the error is due to the fact that cmake is not installed but I’ve included cmake in packages.txt and somehow it doesn’t recognize cmake as well as the other packages at all. Corresponding log is given below:

E: Unable to locate package freeglut3-dev
E: Unable to locate package libgtk2.0-dev
E: Couldn't find any package by glob 'libgtk2.0-dev
E: Couldn't find any package by regex 'libgtk2.0-dev
E: Unable to locate package cmake

Packages.txt file

Link to the hosted app on streamlit

I need to deploy it urgently. So any help is really appreciated.

Hi @Ashish013, welcome to the Streamlit community!

Your link to the packages.txt file doesn’t work, could you post the proper location?


Hey @randyzwitch sorry for the late response. I changed the requirements.txt by adding the packages altair, pandas to the start of the file as given in this example repo. And somehow it was able to read in the packages.txt properly this time. I can’t make sense sense of it but it has solved the problem for me. Thanks a lot for your immediate response.

Ashish M

1 Like

Hello @randyzwitch .I too get the same error while deploying my app. Please help me in resolving this. Here are the errors that encountered:
ERROR: CMake must be installed to build dlib

ERROR: Failed building wheel for dlib

Hi @Pavan_sai_Sheshetti, welcome to the Streamlit community!! :tada: :partying_face:

I’m sorry to hear you had issues with dlib. I tried installing it via pip but couldn’t get it to work. However, it appears to work using conda. Here are the steps you need to follow to successfully deploy your app:

  1. Delete your app from Streamlit Sharing

  2. Delete your requirements.txt file

  3. Create a packages.txt file to install the the apt-get dependencies for dlib. Your packages.txt should contain:

  4. To install Python packages with conda, create an environment.yml file containing the following:

         - conda-forge
         - dlib
         - numpy
         - scipy
         - opencv
         - face_recognition
  5. Deploy your app on Streamlit Sharing :rocket:

Once you follow all the :point_up: steps, your deployed app should look like this:

Feel free to copy the requirements.txt and environment.yml files from my fork of your repo. Let us know if this helps!

Happy Streamlit-ing! :balloon:

Thank you @snehankekre . The WebApp successfully deployed. But there was an error when clicking the start Button.


ERROR: V4L: can't open camera by index 0
2021-05-10 11:41:09.159 Uncaught app exception

Hi @Pavan_sai_Sheshetti, it looks like your application is trying and failing to open a video source with opencv in line 50: cap = cv2.VideoCapture(0) .

The app will work on your local machine as the “server” and “client” are identical. However, if you deploy your app on a remote server (including Streamlit Sharing), opencv will not be able to find the video source (webcam) as none exists.

You will need to use a component to get your users’ webcam feed. @whitphx is the creator of the :fire: awesome :fire: streamlit-webrtc component for real-time video processing. You should be able to use streamlit-webrtc to capture frames from users’ webcam feed and then process them with tools like opencv.

Happy Streamlit-ing! :balloon:


thanks for your .It is really helpful,but another error is coming

StreamlitAPIException: To use Custom Components in Streamlit, you need to install PyArrow. Unfortunately, PyArrow does not yet support Python 3.9.

You can either switch to Python 3.8 with an environment manager like PyEnv, or stay on 3.9 by installing Streamlit with conda:

conda install -c conda-forge streamlit

Actually,I’m running my project in an environment called myvre,can you please help me to change the python version in myvre from 3.9 to 3.8

@Pavan_sai_Sheshetti Sure thing!

You have to activate the myvre environment and then install Python 3.8 like so:

conda activate myvre 
conda install python=3.8
python --version

Best, :balloon:

Thank you, but I’m not using conda,but I created another myvre using virtualenv myvre1 and installed python 3.8 again.(all libraries required for my project)and I installed pyarrow and everything is working fine. But I stuck at using streamlit-webrtc to my project. I read all the articles by @whitphx , But I did not get any. I hope you what my project is,I will mention again
open cv videocapture will get frame by frame from the following commands
ret,img=cap.read() #will capture frame by frame.and it will be passed to my function classify_face(img)
But how can I achieve this using streamlit-webrtc (i.e. to capture by frame and pass it to function )

Thank you,
Pavan Sai