ModuleNotFoundError: No module named 'dlib' in pipenv - python

Sorry I am new to all this.
I can't install dlib inside pipenv virtual environment, however, I able to install and import it outside pipenv virtual env.
When I navigate to the folder containing my code and type pipenv shell and then python3 example.py which is the code I want to run, I get this error:
import dlib
ModuleNotFoundError: No module named 'dlib'
Then I tried to install dlib using these commands:
$ sudo apt-get update
$ sudo apt-get install build-essential cmake
$ sudo apt-get install libopenblas-dev liblapack-dev
$ sudo apt-get install libx11-dev libgtk-3-dev
$ sudo apt-get install python python-dev python-pip
$ sudo apt-get install python3 python3-dev python3-pip
$ pip3 install dlib
everything worked fine except the last command, here is the output I am getting, in red:
$ pip3 install dlib
Collecting dlib
Using cached dlib-19.19.0.tar.gz (3.2 MB)
Building wheels for collected packages: dlib
Building wheel for dlib (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /home/hany/.local/share/virtualenvs/vesselware-rtITNVcC/bin/python3.5m -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-24bjeekz/dlib/setup.py'"'"'; __file__='"'"'/tmp/pip-install-24bjeekz/dlib/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-3n4hx6v_
cwd: /tmp/pip-install-24bjeekz/dlib/
Complete output (292 lines):
running bdist_wheel
running build
running build_py
package init file 'dlib/__init__.py' not found (or not a regular file)
warning: build_py: byte-compiling is disabled, skipping.
running build_ext
Building extension for Python 3.5.9 (default, Nov 24 2019, 01:35:13)
Invoking CMake setup: 'cmake /tmp/pip-install-24bjeekz/dlib/tools/python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/tmp/pip-install-24bjeekz/dlib/build/lib.linux-x86_64-3.5 -DPYTHON_EXECUTABLE=/home/hany/.local/share/virtualenvs/vesselware-rtITNVcC/bin/python3.5m -DCMAKE_BUILD_TYPE=Release'
/tmp/pip-install-24bjeekz/dlib/dlib/external/pybind11/include/pybind11/detail/common.h:111:10: fatal error: Python.h: No such file or directory
#include <Python.h>
^~~~~~~~~~
compilation terminated.
CMakeFiles/dlib_python.dir/build.make:134: recipe for target 'CMakeFiles/dlib_python.dir/src/svm_c_trainer.cpp.o' failed
make[2]: *** [CMakeFiles/dlib_python.dir/src/svm_c_trainer.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/dlib_python.dir/all' failed
make[1]: *** [CMakeFiles/dlib_python.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-24bjeekz/dlib/setup.py", line 261, in <module>
'Topic :: Software Development',
File "/home/hany/.local/share/virtualenvs/vesselware-rtITNVcC/lib/python3.5/site-packages/setuptools/__init__.py", line 145, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python3.5/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.5/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/hany/.local/share/virtualenvs/vesselware-rtITNVcC/lib/python3.5/site-packages/setuptools/command/install.py", line 61, in run
return orig.install.run(self)
File "/usr/lib/python3.5/distutils/command/install.py", line 583, in run
self.run_command('build')
File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib/python3.5/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/tmp/pip-install-24bjeekz/dlib/setup.py", line 135, in run
self.build_extension(ext)
File "/tmp/pip-install-24bjeekz/dlib/setup.py", line 175, in build_extension
subprocess.check_call(cmake_build, cwd=build_folder)
File "/usr/lib/python3.5/subprocess.py", line 271, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--config', 'Release', '--', '-j4']' returned non-zero exit status 2
----------------------------------------
ERROR: Command errored out with exit status 1: /home/hany/.local/share/virtualenvs/vesselware-rtITNVcC/bin/python3.5m -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-24bjeekz/dlib/setup.py'"'"'; __file__='"'"'/tmp/pip-install-24bjeekz/dlib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-ifngrgm8/install-record.txt --single-version-externally-managed --compile --install-headers /home/hany/.local/share/virtualenvs/vesselware-rtITNVcC/include/site/python3.5/dlib Check the logs for full command output.
When I tried doing the same thing outside the virtual env, everything worked fine.
I am out of ideas, I very much appreciate your advice.
Edit 1
I tried installing dlib within the pipenv virtual environment using conda, here is the result:
Launching subshell in virtual environment…
. /home/hano/.local/share/virtualenvs/vesselware-rtITNVcC/bin/activate
hano#hano-asus:~/scripts/vesselware$ . /home/hano/.local/share/virtualenvs/vesselware-rtITNVcC/bin/activate
(vesselware) hano#hano-asus:~/scripts/vesselware$ conda install -c menpo dlib
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: |
Found conflicts! Looking for incompatible packages.
This can take several minutes. Press CTRL-C to abort.
failed
UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:
Specifications:
- dlib -> python[version='2.7.*|3.5.*|>=3.5,<3.6.0a0']
- dlib -> python[version='>=2.7,<2.8.0a0']
Your python: python=3.7
If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.
The following specifications were found to be incompatible with each other:
Package certifi conflicts for:
python=3.7 -> pip -> setuptools -> certifi[version='>=2016.09|>=2016.9.26']
dlib -> python=3.5 -> pip -> setuptools -> certifi[version='>=2016.09|>=2016.9.26']
Package wheel conflicts for:
dlib -> python=3.5 -> pip -> wheel
python=3.7 -> pip -> wheel
Package pip conflicts for:
dlib -> python=3.5 -> pip
python=3.7 -> pip
Package ca-certificates conflicts for:
python=3.7 -> openssl[version='>=1.1.1a,<1.1.2a'] -> ca-certificates
dlib -> python=3.5 -> ca-certificates
Package setuptools conflicts for:
python=3.7 -> pip -> setuptools
dlib -> python=3.5 -> pip -> setuptools
Edit 2
I made sure that pipenv uses python 3.5 (as you can see in the pip3 error above), but I still can't install dlib neither by pip3 nor by conda. And the strange thing is that conda error tells me Your python: python=3.7 while pip3 error states clearly that I am using python 3.5:Building extension for Python 3.5.9
Please advice.

Try the following:
conda create --name python3_5 python=3.5
conda activate python3_5
conda install -c menpo dlib

Related

Cannot install Pyinstaller under Wine on Kali Linux

I am getting syntax error ERROR: Command errored out with exit status 1 ... while trying to install Pyinstaller under Wine on Kali Linux in a virtual environment
I'm getting an error as follows:
┌──(root㉿kali)-[~/.wine/drive_c/Python27/Scripts]
└─# wine ~/.wine/drive_c/Python27/python.exe -m pip install pyinstaller
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrt
Collecting pyinstaller
Using cached https://files.pythonhosted.org/packages/9e/ed/fbdad7f5d8f794c901076b814b8z
Installing build dependencies ... done
Getting requirements to build wheel ... error
ERROR: Command errored out with exit status 1:
command: 'C:\Python27\python.exe' 'C:\Python27\lib\site-packages\pip\_vendor\pep517\_'
cwd: c:\users\root\temp\pip-install-87e3zr\pyinstaller
Complete output (19 lines):
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 207, in>
main()
File "C:\Python27\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 197, inn
json_out['return_val'] = hook(**hook_input['kwargs'])
File "C:\Python27\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 54, in l
return hook(config_settings)
File "c:\users\root\temp\pip-build-env-fbjbxm\overlay\Lib\site-packages\setuptools\bl
return self._get_build_requires(config_settings, requirements=['wheel'])
File "c:\users\root\temp\pip-build-env-fbjbxm\overlay\Lib\site-packages\setuptools\bs
self.run_setup()
File "c:\users\root\temp\pip-build-env-fbjbxm\overlay\Lib\site-packages\setuptools\bp
self).run_setup(setup_script=setup_script)
File "c:\users\root\temp\pip-build-env-fbjbxm\overlay\Lib\site-packages\setuptools\bp
exec(compile(code, __file__, 'exec'), locals())
File "setup.py", line 63
file=sys.stderr)
^
SyntaxError: invalid syntax
----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Python27\python.exe' 'C:\Python27\lib.
WARNING: You are using pip version 19.2.3, however version 20.3.4 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
I have python2 version 2.7.18 and python version 3.9.10 installed and pip 22.1.2 from /usr/local/lib/python3.9/dist-packages/pip. I have tried uninstalling and reinstalling Python, Wine but the error doesn't go away.
The latest PyInstaller version for Python2.7 is 3.6.
So you need to tell pip which PyInstaller version to install:
...python.exe -m pip install pyinstaller==3.6

Error with Dlib installation for python on windows 10

I'm trying to install dlib. I followed every single tip on the internet but its just not working.
I'm using/tried
windows 10
cmake 3.21.4 (it's on path)
python 3.8.12 and 3.6.4
conda 4.10.3
pip 21.3.1
visual studio 2019
components in vs (1)
components in vs (2)
I have conda and pip installed, tried both with
pip install dlib
pip install dlib --verbose
pip install "some urls"
conda install -c conda-forge dlib
conda install -c conda-forge/label/cf201901 dlib
The error I'm getting is:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\sophi\AppData\Local\Temp\pip-install-3w7lgrlb\dlib_ffabe5e6a08e472b835f598e7803e3d4\setup.py", line 222, in <module>
setup(
File "c:\users\sophi\anaconda3\lib\site-packages\setuptools\__init__.py", line 159, in setup
return distutils.core.setup(**attrs)
File "c:\users\sophi\anaconda3\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "c:\users\sophi\anaconda3\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "c:\users\sophi\anaconda3\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "c:\users\sophi\anaconda3\lib\site-packages\setuptools\command\install.py", line 68, in run
return orig.install.run(self)
File "c:\users\sophi\anaconda3\lib\distutils\command\install.py", line 545, in run
self.run_command('build')
File "c:\users\sophi\anaconda3\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "c:\users\sophi\anaconda3\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "c:\users\sophi\anaconda3\lib\distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "c:\users\sophi\anaconda3\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "c:\users\sophi\anaconda3\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\sophi\AppData\Local\Temp\pip-install-3w7lgrlb\dlib_ffabe5e6a08e472b835f598e7803e3d4\setup.py", line 134, in run
self.build_extension(ext)
File "C:\Users\sophi\AppData\Local\Temp\pip-install-3w7lgrlb\dlib_ffabe5e6a08e472b835f598e7803e3d4\setup.py", line 174, in build_extension
subprocess.check_call(cmake_build, cwd=build_folder)
File "c:\users\sophi\anaconda3\lib\subprocess.py", line 364, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--config', 'Release', '--', '/m']' returned non-zero exit status 1.
Running setup.py install for dlib ... error
ERROR: Command errored out with exit status 1: 'c:\users\sophi\anaconda3\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\sophi\\AppData\\Local\\Temp\\pip-install-3w7lgrlb\\dlib_ffabe5e6a08e472b835f598e7803e3d4\\setup.py'"'"'; __file__='"'"'C:\\Users\\sophi\\AppData\\Local\\Temp\\pip-install-3w7lgrlb\\dlib_ffabe5e6a08e472b835f598e7803e3d4\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\sophi\AppData\Local\Temp\pip-record-kvd3vwdq\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\sophi\anaconda3\Include\dlib' Check the logs for full command output.
For me, it seems like the problem is somethin with the cmake command, but I have no idea what the exact problem is. I used pip install cmake and installed cmake from source, none of both worked.
Has anyone an idea how to solve this?
This may be late response but I was facing the exact same issue when trying to install dlib on visual studio code. This was my error I was receiving when trying to run the command "pip install dlib"
Collecting dlib
Using cached dlib-19.23.1.tar.gz (7.4 MB)
Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for dlib, since package 'wheel' is not installed.
Installing collected packages: dlib
Running setup.py install for dlib ... error
error: subprocess-exited-with-error
× Running setup.py install for dlib did not run successfully.
│ exit code: 1
╰─> [8 lines of output]
running install
running build
running build_py
package init file 'tools\python\dlib\__init__.py' not found (or not a regular file)
running build_ext
ERROR: CMake must be installed to build dlib
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> dlib
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
So my next approach was to install cmake which where the installation worked however I receive a warning that the file path to the exe was not added to my path. This resulted when running "cmake --version" to outputted in terminal
'cmake' is not recognized as an internal or external command,
operable program or batch file.
I would suspected to not run correctly, and to fix this I simply copy the path that it had printed out to my terminal after install cmake and went to
Advance System Settings -> Advanced Tab -> Environment Variables -> User Variables for 'your desktop name' open up "Path" -> click on new -> paste path
After following those steps running the command "cmake --version" correctly printed out the version install, meaning it is accessing the correct path. After that "pip install dlib" worked perfectly as proof below
Collecting dlib
Using cached dlib-19.23.1.tar.gz (7.4 MB)
Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for dlib, since package 'wheel' is not installed.
Installing collected packages: dlib
Running setup.py install for dlib ... done
Successfully installed dlib-19.23.1
I hope this may help as it is one approach that worked for me in installing dlib. As you mention your cmake is on path I would check by running the command to see if the version is correctly printing out.
Althoug trying to test every combination of the commands mentioned in my question, there apparently was one combination I didn't try:
Conda environment with python 3.6.4 and then
conda install -c conda-forge dlib
Not able to install dlib on Windows 10 and Python 3.7
As Berkay is mentioning, anaconda apparently requires python <=3.6.x, which solved it for me.
! pip install dlib would not work in this environment (probably because of another version problem with this environment) !

Cant install PyNaCl with pip inside a PyCharm venv

Using python3.8.1, installing newest version, on Windows 10:
pip install PyNaCl gives me this error (last 10 lines):
File "C:\Program Files (x86)\Python3\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Program Files (x86)\Python3\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "setup.py", line 161, in run
raise Exception("ERROR: The 'make' utility is missing from PATH")
Exception: ERROR: The 'make' utility is missing from PATH
----------------------------------------
Failed building wheel for PyNaCl
Running setup.py clean for PyNaCl
Failed to build PyNaCl
Could not build wheels for PyNaCl which use PEP 517 and cannot be installed directly
It seems to be related to wheels, so i tried to install it with no-binary, which also failed:
File "C:\Program Files (x86)\Python3\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\Administrator\AppData\Local\Temp\pip-install-q0db5s_n\PyNaCl\setup.py", line 161, in run
raise Exception("ERROR: The 'make' utility is missing from PATH")
Exception: ERROR: The 'make' utility is missing from PATH
----------------------------------------
Command "C:\Users\Administrator\Documents\DiscordBot\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-q0db5s_n\\PyNaCl\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Administrator\AppData\Local\Temp\pip-record-s27dvlrv\install-record.txt --single-version-externally-managed --compile --install-headers C:\Users\Administrator\Documents\DiscordBot\venv\include\site\python3.8\PyNaCl" failed with error code 1 in C:\Users\Administrator\AppData\Local\Temp\pip-install-q0db5s_n\PyNaCl\
EDIT: This only seems to be an issue in my venv (made by Pycharm) - i have no clue what the issue is, both setuptools and wheel are installed.
I ultimately solved it by using python -m pip install --no-use-pep517 pynacl
Upgrading pip within the venv worked for me:
.\env\Scripts\activate
pip install -U pip
pip install -r requirements.txt
deactivate

ModuleNotFoundError: No module named ‘tools.nnwrap’ (windows)

I am trying to install PyTorch but every time it throws the same error ( ModuleNotFoundError: No module named ‘tools.nnwrap’).
This is what is typed: pip install torch
This is what I get every time:
Collecting torch
Using cached https://files.pythonhosted.org/packages/f8/02/880b468bd382dc79896eaecbeb8ce95e9c4b99a24902874a2cef0b562cea/torch-0.1.2.post2.tar.gz
Requirement already satisfied: pyyaml in c:\users\user\appdata\local\programs\python\python37-32\lib\site-packages (from torch) (5.1.2)
Installing collected packages: torch
Running setup.py install for torch … error
ERROR: Command errored out with exit status 1:
command: ‘c:\users\user\appdata\local\programs\python\python37-32\python.exe’ -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"‘C:\Users\User\AppData\Local\Temp\pip-install-oegjniuy\torch\setup.py’"’"’; file=’"’"‘C:\Users\User\AppData\Local\Temp\pip-install-oegjniuy\torch\setup.py’"’"’;f=getattr(tokenize, ‘"’"‘open’"’"’, open)(file);code=f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ install --record ‘C:\Users\User\AppData\Local\Temp\pip-record-b_c49sh\install-record.txt’ --single-version-externally-managed --compile
cwd: C:\Users\User\AppData\Local\Temp\pip-install-oegjniuy\torch
Complete output (23 lines):
running install
running build_deps
Traceback (most recent call last):
File “<string>”, line 1, in <module>
File “C:\Users\User\AppData\Local\Temp\pip-install-oegjniuy\torch\setup.py”, line 265, in
description=“Tensors and Dynamic neural networks in Python with strong GPU acceleration”,
File "C:\Users\User\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\setuptools_init.py", line 145, in setup
return distutils.core.setup(**attrs)
File “C:\Users\User\AppData\Local\Programs\Python\Python37-32\Lib\distutils\core.py”, line 148, in setup
dist.run_commands()
File “C:\Users\User\AppData\Local\Programs\Python\Python37-32\Lib\distutils\dist.py”, line 966, in run_commands
self.run_command(cmd)
File “C:\Users\User\AppData\Local\Programs\Python\Python37-32\Lib\distutils\dist.py”, line 985, in run_command
cmd_obj.run()
File “C:\Users\User\AppData\Local\Temp\pip-install-oegjniuy\torch\setup.py”, line 99, in run
self.run_command(‘build_deps’)
File “C:\Users\User\AppData\Local\Programs\Python\Python37-32\Lib\distutils\cmd.py”, line 313, in run_command
self.distribution.run_command(command)
File “C:\Users\User\AppData\Local\Programs\Python\Python37-32\Lib\distutils\dist.py”, line 985, in run_command
cmd_obj.run()
File “C:\Users\User\AppData\Local\Temp\pip-install-oegjniuy\torch\setup.py”, line 51, in run
from tools.nnwrap import generate_wrappers as generate_nn_wrappers
ModuleNotFoundError: No module named ‘tools.nnwrap’
----------------------------------------
ERROR: Command errored out with exit status 1: ‘c:\users\user\appdata\local\programs\python\python37-32\python.exe’ -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"‘C:\Users\User\AppData\Local\Temp\pip-install-oegjniuy\torch\setup.py’"’"’; file=’"’"‘C:\Users\User\AppData\Local\Temp\pip-install-oegjniuy\torch\setup.py’"’"’;f=getattr(tokenize, ‘"’"‘open’"’"’, open)(file);code=f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ install --record ‘C:\Users\User\AppData\Local\Temp\pip-record-_b_c49sh\install-record.txt’ --single-version-externally-managed --compile Check the logs for full command output.
Do anyone knows how to fix this error!!
# for OS: Windows, package: pip, Language: python3.6 (below command is valid for only mentioned python 3.6)
pip3 install https://download.pytorch.org/whl/cu90/torch-1.1.0-cp36-cp36m-win_amd64.whl
pip3 install https://download.pytorch.org/whl/cu90/torchvision-0.3.0-cp36-cp36m-win_amd64.whl
For another version/type of the software (OS, package, Language) installed, the command must be generated from the below-mentioned link: https://pytorch.org/get-started/locally/
It is recommended to directly get the desired URL that matches system configuration from the Pytorch website-https://pytorch.org/get-started/locally/
Select the options that meet your system config and using anaconda pip install the url
Try to paste the command
pip install torch==1.7.1+cpu torchvision==0.8.2+cpu torchaudio===0.7.2 -f https://download.pytorch.org/whl/torch_stable.html
in the Anaconda Prompt. Worked for me.

failing to install dlib on windows 10 [duplicate]

This question already has answers here:
dlib installation on Windows 10
(19 answers)
Closed 3 months ago.
Trying to install dlib on Windows 10 using pycharm package manager.
I have Numpy, opencv-python, setuptools and wheel installed.
tried installing dlib then got the first error asking me to install CMake.
Now I'm getting this:
(tried installing visual studio but it had no effect).
Collecting dlib Using cached https://files.pythonhosted.org/packages/d5/5c/aa64510aa354d562ecba7edecd500b020280741140e5d91ff5ec1c6f8289/dlib-19.13.1.tar.gz Building wheels for collected packages: dlib Running setup.py bdist_wheel for dlib: started Running setup.py bdist_wheel for dlib: finished with status 'error' Complete output from command C:\Users\Tom\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Tom\\AppData\\Local\\Temp\\pycharm-packaging\\dlib\\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 C:\Users\Tom\AppData\Local\Temp\pip-wheel-f_njkl2_ --python-tag cp36: running bdist_wheel running build running build_py package init file 'dlib\__init__.py' not found (or not a regular file) warning: build_py: byte-compiling is disabled, skipping.
running build_ext Building extension for Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] Invoking CMake setup: 'cmake C:\Users\Tom\AppData\Local\Temp\pycharm-packaging\dlib\tools\python
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Tom\AppData\Local\Temp\pycharm-packaging\dlib\build\lib.win32-3.6
-DPYTHON_EXECUTABLE=C:\Users\Tom\venv\Scripts\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\Tom\AppData\Local\Temp\pycharm-packaging\dlib\build\lib.win32-3.6'
-- Building for: NMake Makefiles -- The C compiler identification is unknown -- The CXX compiler identification is unknown CMake Error in CMakeLists.txt:
The CMAKE_C_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C++, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt (vcvarsall.bat).
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.
CMake Error in CMakeLists.txt:
The CMAKE_CXX_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C++, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt (vcvarsall.bat).
Tell CMake where to find the compiler by setting either the environment
variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.
-- Configuring incomplete, errors occurred! See also "C:/Users/Tom/AppData/Local/Temp/pycharm-packaging/dlib/build/temp.win32-3.6/Release/CMakeFiles/CMakeOutput.log". See also "C:/Users/Tom/AppData/Local/Temp/pycharm-packaging/dlib/build/temp.win32-3.6/Release/CMakeFiles/CMakeError.log". Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\Tom\AppData\Local\Temp\pycharm-packaging\dlib\setup.py", line 256, in <module>
'Topic :: Software Development',
File "C:\Users\Tom\venv\lib\site-packages\setuptools-39.1.0-py3.6.egg\setuptools\__init__.py", line 129, in setup
File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\Tom\venv\lib\site-packages\wheel\bdist_wheel.py", line 202, in run
self.run_command('build')
File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\Tom\AppData\Local\Temp\pycharm-packaging\dlib\setup.py", line 133, in run
self.build_extension(ext)
File "C:\Users\Tom\AppData\Local\Temp\pycharm-packaging\dlib\setup.py", line 169, in build_extension
subprocess.check_call(cmake_setup, cwd=build_folder)
File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 291, in check_call
raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\Tom\\AppData\\Local\\Temp\\pycharm-packaging\\dlib\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\Tom\\AppData\\Local\\Temp\\pycharm-packaging\\dlib\\build\\lib.win32-3.6', '-DPYTHON_EXECUTABLE=C:\\Users\\Tom\\venv\\Scripts\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\Tom\\AppData\\Local\\Temp\\pycharm-packaging\\dlib\\build\\lib.win32-3.6']' returned non-zero exit status 1.
---------------------------------------- Running setup.py clean for dlib Failed to build dlib Installing collected packages: dlib Running setup.py install for dlib: started
Running setup.py install for dlib: finished with status 'error'
Complete output from command C:\Users\Tom\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Tom\\AppData\\Local\\Temp\\pycharm-packaging\\dlib\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install
--record C:\Users\Tom\AppData\Local\Temp\pip-record-1kold5c8\install-record.txt
--single-version-externally-managed --compile --install-headers C:\Users\Tom\venv\include\site\python3.6\dlib:
running install
running build
running build_py
package init file 'dlib\__init__.py' not found (or not a regular file)
warning: build_py: byte-compiling is disabled, skipping.
running build_ext
Building extension for Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)]
Invoking CMake setup: 'cmake C:\Users\Tom\AppData\Local\Temp\pycharm-packaging\dlib\tools\python
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Tom\AppData\Local\Temp\pycharm-packaging\dlib\build\lib.win32-3.6
-DPYTHON_EXECUTABLE=C:\Users\Tom\venv\Scripts\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\Tom\AppData\Local\Temp\pycharm-packaging\dlib\build\lib.win32-3.6'
-- Building for: NMake Makefiles
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error in CMakeLists.txt:
The CMAKE_C_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C++, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt (vcvarsall.bat).
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.
CMake Error in CMakeLists.txt:
The CMAKE_CXX_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C++, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt (vcvarsall.bat).
Tell CMake where to find the compiler by setting either the environment
variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.
-- Configuring incomplete, errors occurred!
See also "C:/Users/Tom/AppData/Local/Temp/pycharm-packaging/dlib/build/temp.win32-3.6/Release/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Tom/AppData/Local/Temp/pycharm-packaging/dlib/build/temp.win32-3.6/Release/CMakeFiles/CMakeError.log".
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\Tom\AppData\Local\Temp\pycharm-packaging\dlib\setup.py", line 256, in <module>
'Topic :: Software Development',
File "C:\Users\Tom\venv\lib\site-packages\setuptools-39.1.0-py3.6.egg\setuptools\__init__.py", line 129, in setup
File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\Tom\venv\lib\site-packages\setuptools-39.1.0-py3.6.egg\setuptools\command\install.py", line 61, in run
File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\command\install.py", line 545, in run
self.run_command('build')
File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\Tom\AppData\Local\Temp\pycharm-packaging\dlib\setup.py", line 133, in run
self.build_extension(ext)
File "C:\Users\Tom\AppData\Local\Temp\pycharm-packaging\dlib\setup.py", line 169, in build_extension
subprocess.check_call(cmake_setup, cwd=build_folder)
File "C:\Users\Tom\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 291, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\Tom\\AppData\\Local\\Temp\\pycharm-packaging\\dlib\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\Tom\\AppData\\Local\\Temp\\pycharm-packaging\\dlib\\build\\lib.win32-3.6', '-DPYTHON_EXECUTABLE=C:\\Users\\Tom\\venv\\Scripts\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\Tom\\AppData\\Local\\Temp\\pycharm-packaging\\dlib\\build\\lib.win32-3.6']' returned non-zero exit status 1.
----------------------------------------
Failed building wheel for dlib Command "C:\Users\Tom\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Tom\\AppData\\Local\\Temp\\pycharm-packaging\\dlib\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install
--record C:\Users\Tom\AppData\Local\Temp\pip-record-1kold5c8\install-record.txt
--single-version-externally-managed --compile --install-headers C:\Users\Tom\venv\include\site\python3.6\dlib" failed with error code 1 in C:\Users\Tom\AppData\Local\Temp\pycharm-packaging\dlib\
What am I missing here?
I'm really baffled.
pip install https://pypi.python.org/packages/da/06/bd3e241c4eb0a662914b3b4875fc52dd176a9db0d4a2c915ac2ad8800e9e/dlib-19.7.0-cp36-cp36m-win_amd64.whl#md5=b7330a5b2d46420343fbed5df69e6a3f
Try this cmd command, it worked for me
I have followed below steps to install face_recognition (dlib):-
Re-installed Python 3.6.6 (https://www.python.org/ftp/python/3.6.6/python-3.6.6-amd64.exe).
pip3 install cmake
pip3 install dlib
pip3 install face_recognition
It worked for me.
If you have conda installed in your system then follow these steps:
conda create -n py36 python=3.6
activate py36
conda config --add channels conda-forge
conda install numpy
conda install scipy
conda install dlib
I know this question is for windows, But by chance if someone is looking for solution for this on Mac,
Try this command, worked for me
pip install https://files.pythonhosted.org/packages/05/57/e8a8caa3c89a27f80bc78da39c423e2553f482a3705adc619176a3a24b36/dlib-19.17.0.tar.gz#SHA256=92587c81b0165e933593f505fdf099dface0d0f8ec874b1d8655fc774598911f
if you have installed Visual Studio, you need to make sure that you have selected Clang tools
Also use command Prompt (cmd) and be patient when pip install dlib it will take more than 5 min to be compiled
Please follow the below steps:
install Python version you like
install cmake from https://cmake.org/download/ and add it to the path when install it
install visual studio from https://visualstudio.microsoft.com/visual-cpp-build-tools, then go to modify -> individual components -> choose the following:
(MSBuild/MSVC v142 - VS 2019 C++ x64/x86 build tools (v14.27)/C++ 2019 Redistributable Update/C++ CMake tools for Windows/C++/CLI support for v142 build tools (14.27)/C++ Clang-cl for v142 build tools (x64/x86)/C++ Clang Compiler for Windows (10.0.0)/Windows Universal CRT SDK/MSVC v140 - VS 2015 C++ build tools (v14.00)/Windows 10 SDK (10.0.19041.0)/C++ 2019 Redistributable MSMs))
open the visual studio and create new project as cmake c++
you will be prompt to update the windows 10 sdk after building the project
install updates for SDK
go to windows terminal
pip install dlib
this works perfectly for me.
Thanks
The error is telling you the answer. The CMAKE_C_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C++, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt (vcvarsall.bat)."
Try to compile using the Visual Studio command prompt. The path to it there should be correct too.
The best method to install dlib and openCV is given here.
It simply uses pip to perform all the installations.
The major things that people miss or do a mistake in for Windows are declaring the PATH variables and saving them to valid address in your pc apart from the proper version matching. The above blog clearly signifies the versions to be used and declarations of PATH variables.
Just a 3 step process:-
Install anaconda
Activate Virtual Environment
Install openCV and dlib using pip (or any other required packages)
Linux error solution
$ sudo apt-get install build-essential cmake
$ sudo apt-get install libgtk-3-dev
$ sudo apt-get install libboost-all-dev
$ pip3 install dilb
Use the following code in the terminal which is accessible through Alt+F12 on your keyboard.
pip install dlib==19.8.1
You should be good to go.

Categories

Resources