38

I've got a fresh installation of Python 3.6 + Selenium and now want to install Clarifai 2.0.21.

The following command is failing:

python -m pip install clarifai==2.0.21

At first it requested VC++ 14.0 but I had 14.1 (with VS2017), so I installed VC++2015 BuildTools which has 14.0. This worked partly until creating the library.

I got the new error as next:

Generating code
Finished generating code
LINK : fatal error LNK1158: cannot run 'rc.exe' error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\link.exe' failed with exit status 1158

Any idea if there's something missing in my installation? Thank You

atline
  • 28,355
  • 16
  • 77
  • 113
Sundancer
  • 536
  • 1
  • 4
  • 12

3 Answers3

152

I had a similar problem today, and I solved it referring to

Visual Studio can't build due to rc.exe.

To fix the issue, do next steps:

  1. Add this to your PATH environment variables:

    C:\Program Files (x86)\Windows Kits\10\bin\x64

  2. Copy these files rc.exe & rcdll.dll from C:\Program Files (x86)\Windows Kits\8.1\bin\x86 to C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin

In newer Windows these files might also be in the highest version: C:\Program Files (x86)\Windows Kits\10\bin\10.0.VERSION\x86

Community
  • 1
  • 1
joe
  • 1,546
  • 1
  • 9
  • 4
  • 19
    My goodness this issuess... Anyway doing just step2 was enough for me. Thanks a lot! – Gaspa79 Jul 24 '17 at 17:15
  • @joe, thanks a lot, following from #2 helped me too. I had a problem installing Twisted as a dependency for Scrapy – Nick Aug 20 '17 at 16:47
  • These steps also worked for me when I was trying to install oscodepoint and had the same error – Ed Harrod Oct 05 '17 at 09:31
  • 5
    You could also just APPEND C:\Program Files (x86)\Windows Kits\8.1\bin\x86 to your PATH variable with: set PATH=%PATH%;C:\Program Files (x86)\Windows Kits\8.1\bin\x86\ – lbenini Dec 12 '17 at 18:42
  • While this answer may work, it feels wrong because it's mixing up x86 and x64 specific files. – John Jefferies Mar 14 '18 at 11:16
  • 1
    I am looking to try this, as I was having a Link1158 error for python build. I am unable to find rc.exe and rcdll.dll in the location listed here. – Jesh Kundem Nov 01 '18 at 14:28
  • 2
    These also worked on Cython failing `setup.py` builds – sawyermclane Nov 07 '18 at 22:15
  • Worked for me too! Tried to install mod-wsgi with PIP. Thanks. – uwain12345 Feb 06 '19 at 14:59
  • 10
    I have Windows 10 and `Windows Kits` contains only `10` folder. The `rc.exe` and `rcdll.dll` are available under `C:\Program Files (x86)\Windows Kits\10\bin\VERSION_NUMBER\x86` and multiiple VERSION_NUMBER folders are present. I copied these two files from the folder with the highest version number and it worked. – user3855877 Mar 27 '19 at 08:57
  • Thanks joe, worked for me on Python 3.6.1 in Windows 10 with MS Visual Studio Build Tools 2019 – Remo Harsono Nov 15 '22 at 21:15
  • Commenting to add that this answer also helped me solve `link.exe failed with exit code 1327` – Tom Dec 01 '22 at 17:54
  • This is priceless. But the question is, How the hell can we know this? And solve such errors!!!! – Hasan Shouman Aug 01 '23 at 11:12
16

I had the very same problem when using PIP / Python 3.5 and Visual Studio 2017 while installing librosa using pip (and it's dependency resampy)

Solved the problem using the Visual Studio 2017 Developer prompt and running pip install from there.

Hope that helps someone.

Ric Hard
  • 599
  • 4
  • 12
10

In case this helps someone. The original problem didn't occur for me with a baseline VS2015. I now see the same problem with the LNK1158 error. I surmise because I'm now using VS2015 Update 2, which uses rc.exe from "C:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x64". The solution is similar to another answer. It is to either copy or take a symlink of rc.exe and rcdll.dll from:

    C:\Program Files (x86)\Windows Kits\10\bin\10.0.16299.0\x64

to

    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64
John Jefferies
  • 1,176
  • 7
  • 13