kurtbrose / pyjks

a pure python Java KeyStore file parser, including private key decryption
MIT License
129 stars 35 forks source link

Unable to install python package with pip, getting Microsoft Visual C++ 14.0 is required #40

Open Mahesha999 opened 6 years ago

Mahesha999 commented 6 years ago

I am trying to install pyjks in Windows 10. Am running everything in admin command prompt. Initial try to install pyjks resulted in this:

C:\WINDOWS\system32>pip install pyjks
Collecting pyjks
Collecting pycryptodome (from pyjks)
  Using cached https://files.pythonhosted.org/packages/82/bd/bd192c1314bde108a91295fbec02bc20a816330feb10273aa36d885004ab/pycryptodome-3.6.1-cp36-cp36m-win_amd64.whl
Collecting pyasn1-modules (from pyjks)
  Using cached https://files.pythonhosted.org/packages/e9/51/bcd96bf6231d4b2cc5e023c511bee86637ba375c44a6f9d1b4b7ad1ce4b9/pyasn1_modules-0.2.1-py2.py3-none-any.whl
Collecting pyasn1 (from pyjks)
  Using cached https://files.pythonhosted.org/packages/a0/70/2c27740f08e477499ce19eefe05dbcae6f19fdc49e9e82ce4768be0643b9/pyasn1-0.4.3-py2.py3-none-any.whl
Collecting twofish (from pyjks)
  Using cached https://files.pythonhosted.org/packages/82/b4/9eb026a8e62a04512435d3de25c93f7bda51c8b8c7991c1c0be70b5115a6/twofish-0.3.0.tar.gz
Collecting javaobj-py3 (from pyjks)
  Using cached https://files.pythonhosted.org/packages/6a/7d/1979d67bb8f6c5babb8dda0cb79d6d4663ef9a039c193b5adcc787a86285/javaobj_py3-0.2.4-py2.py3-none-any.whl
Installing collected packages: pycryptodome, pyasn1, pyasn1-modules, twofish, javaobj-py3, pyjks
  Running setup.py install for twofish ... error
    Complete output from command "c:\program files\python36\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\crrma\\AppData\\Local\\Temp\\pip-install-xlk00hde\\twofish\\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\crrma\AppData\Local\Temp\pip-record-5jn53157\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.6
    copying twofish.py -> build\lib.win-amd64-3.6
    running build_ext
    building '_twofish' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

    ----------------------------------------
Command ""c:\program files\python36\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\crrma\\AppData\\Local\\Temp\\pip-install-xlk00hde\\twofish\\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\crrma\AppData\Local\Temp\pip-record-5jn53157\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\crrma\AppData\Local\Temp\pip-install-xlk00hde\twofish\

I installed Visual C++ 14.0 from here and tried reinstalling. But got same error. (Someone on stackoverflow said that this is not C++ compiler but are runtime components. Do I have to install full Visual Studio with C++ compiler just for installing pyjks package?)

So as suggested in several comments on this page, I upgraded setuptools:

C:\WINDOWS\system32>pip install --upgrade setuptools
Collecting setuptools
  Using cached https://files.pythonhosted.org/packages/7f/e1/820d941153923aac1d49d7fc37e17b6e73bfbd2904959fffbad77900cf92/setuptools-39.2.0-py2.py3-none-any.whl
Installing collected packages: setuptools
  Found existing installation: setuptools 39.0.1
    Uninstalling setuptools-39.0.1:
      Successfully uninstalled setuptools-39.0.1
Successfully installed setuptools-39.2.0

But still getting the same error. So as suggested on same page, I downloaded tar.gz from here and installed from it:

C:\Users\crrma\Downloads>pip install pyjks-17.1.1.tar.gz
Processing c:\users\crrma\downloads\pyjks-17.1.1.tar.gz
Requirement already satisfied: pyasn1 in c:\program files\python36\lib\site-packages (from pyjks==17.1.1) (0.4.3)
Requirement already satisfied: pyasn1_modules in c:\program files\python36\lib\site-packages (from pyjks==17.1.1) (0.2.1)
Collecting javaobj-py3 (from pyjks==17.1.1)
  Using cached https://files.pythonhosted.org/packages/6a/7d/1979d67bb8f6c5babb8dda0cb79d6d4663ef9a039c193b5adcc787a86285/javaobj_py3-0.2.4-py2.py3-none-any.whl
Requirement already satisfied: pycryptodome in c:\program files\python36\lib\site-packages (from pyjks==17.1.1) (3.6.1)
Collecting twofish (from pyjks==17.1.1)
  Using cached https://files.pythonhosted.org/packages/82/b4/9eb026a8e62a04512435d3de25c93f7bda51c8b8c7991c1c0be70b5115a6/twofish-0.3.0.tar.gz
Installing collected packages: javaobj-py3, twofish, pyjks
  Running setup.py install for twofish ... error
    Complete output from command "c:\program files\python36\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\crrma\\AppData\\Local\\Temp\\pip-install-c3n_0udc\\twofish\\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\crrma\AppData\Local\Temp\pip-record-tpgigq69\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.6
    copying twofish.py -> build\lib.win-amd64-3.6
    running build_ext
    building '_twofish' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

    ----------------------------------------
Command ""c:\program files\python36\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\crrma\\AppData\\Local\\Temp\\pip-install-c3n_0udc\\twofish\\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\crrma\AppData\Local\Temp\pip-record-tpgigq69\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\crrma\AppData\Local\Temp\pip-install-c3n_0udc\twofish\

But its simply not getting installed. Whats going wrong here?

I am running latest version of python:

C:\>python
Python 3.6.6rc1 (v3.6.6rc1:1015e38be4, Jun 12 2018, 08:38:06) [MSC v.1900 64 bit (AMD64)] on win32
jcdevil commented 6 years ago

It seems there are some libs depending on C/C++ code that have to be compiled. You probably need to install this on your machine : https://go.microsoft.com/fwlink/?LinkId=691126 Notice that I had quite the same issue with another libs, and found the solution here : https://stackoverflow.com/questions/47253638/error-microsoft-visual-c-14-0-is-required-when-installing-python-package HTH ;)

kashperanto commented 5 years ago

I am not having this issue with the same package, but Google brought me here in my search for an answer to the same problem installing a different package (pycryptodome). I found the answer with some good old-fashioned trial and error, but I figured someone else could use this knowledge in the future ;)

It turns out that the requirements.txt file we were using to install an in-house tool was specifying an exact version number (==) for the package. Changing the requirement to >= solved the issue, and pip installed the oldest compatible version with no compilation required.

As for why this is the case, python packages must be compiled with the same C compiler that was used to compile python itself. I'm betting that the pre-compiled wheels for older versions of the library on the package index are incompatible with newer versions of python.

Hopefully this saves someone some digging in the future.

mindw commented 5 years ago

@jcdevil Any chance making TwoFish optional?

jcdevil commented 5 years ago

@mindw : no idea, I do not know how deep is this lib used in pyjks

FrugalGuy commented 4 years ago

See my pull request for updating the doc to list out exactly what is required for Windows in terms of C++ dependencies.

Cosmicoppai commented 4 years ago

Please download Visual C++ Build Tools

Install the visualcppbuildtools_full from 1.

Please ensure below dependencies were installed: Python later then 2.6, including Python 3.x, NumPy, SciPy, Pandas, Patsy, Cython After all the dependencies and visualcppbuildtools_full are installed, please relaunch your IDE or reboot computer. Please execute "pip3 install statsmodels" again after IDE relaunch. I'm using Windows VS code, and I found the statsmodels installation won't work unless I relaunch my VS code.

Please try it.