Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to install qsimcirq on Windows #259

Open
sorin-bolos opened this issue Dec 28, 2020 · 2 comments
Open

Unable to install qsimcirq on Windows #259

sorin-bolos opened this issue Dec 28, 2020 · 2 comments
Assignees

Comments

@sorin-bolos
Copy link

I tried to install qsimcirq on my Windows machine by running pip install qsimcirq. I have a virtual environment with python 3.7 and I've already installed CMake.

I get the following error

 ERROR: Command errored out with exit status 1:
   command: 'C:\Users\Sorin\Anaconda3\envs\cirq\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Sorin\\AppData\\Local\\Temp\\pip-install-2moej2xu\\qsimcirq_2bac09547c194fe49942fe3d07d88005\\setup.py'"'"'; __file__='"'"'C:\\Users\\Sorin\\AppData\\Local\\Temp\\pip-install-2moej2xu\\qsimcirq_2bac09547c194fe49942fe3d07d88005\\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\Sorin\AppData\Local\Temp\pip-wheel-lfoqrxa_'
       cwd: C:\Users\Sorin\AppData\Local\Temp\pip-install-2moej2xu\qsimcirq_2bac09547c194fe49942fe3d07d88005\
  Complete output (79 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.7
  creating build\lib.win-amd64-3.7\qsimcirq
  copying qsimcirq\qsimh_simulator.py -> build\lib.win-amd64-3.7\qsimcirq
  copying qsimcirq\qsim_circuit.py -> build\lib.win-amd64-3.7\qsimcirq
  copying qsimcirq\qsim_simulator.py -> build\lib.win-amd64-3.7\qsimcirq
  copying qsimcirq\__init__.py -> build\lib.win-amd64-3.7\qsimcirq
  running build_ext
  -- Building for: Visual Studio 16 2019
  -- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
  -- The C compiler identification is MSVC 19.28.29335.0
  -- The CXX compiler identification is MSVC 19.28.29335.0
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Found PythonInterp: C:/Users/Sorin/Anaconda3/envs/cirq/python.exe (found version "3.7.9")
  -- Found PythonLibs: C:/Users/Sorin/Anaconda3/envs/cirq/libs/Python37.lib
  -- pybind11 v2.2.4
  -- Performing Test HAS_MSVC_GL_LTCG
  -- Performing Test HAS_MSVC_GL_LTCG - Failed
  -- LTO disabled (not supported by the compiler and/or linker)
  -- Configuring done
  -- Generating done
  -- Build files have been written to: C:/Users/Sorin/AppData/Local/Temp/pip-install-2moej2xu/qsimcirq_2bac09547c194fe49942fe3d07d88005/build/temp.win-amd64-3.7/Release
  Microsoft (R) Build Engine version 16.8.2+25e4d540b for .NET Framework
  Copyright (C) Microsoft Corporation. All rights reserved.

  C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(495,5): warning MSB8029: The Intermediate directory or Output directory cannot reside under the Temporary directory as it could lead to issues with incremental build. [C:\Users\Sorin\AppData\Local\Temp\pip-install-2moej2xu\qsimcirq_2bac09547c194fe49942fe3d07d88005\build\temp.win-amd64-3.7\Release\ZERO_CHECK.vcxproj]
    Checking Build System
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(495,5): warning MSB8029: The Intermediate directory or Output directory cannot reside under the Temporary directory as it could lead to issues with incremental build. [C:\Users\Sorin\AppData\Local\Temp\pip-install-2moej2xu\qsimcirq_2bac09547c194fe49942fe3d07d88005\build\temp.win-amd64-3.7\Release\qsim.vcxproj]
    Building Custom Rule C:/Users/Sorin/AppData/Local/Temp/pip-install-2moej2xu/qsimcirq_2bac09547c194fe49942fe3d07d88005/CMakeLists.txt
  cl : command line warning D9002: ignoring unknown option '-O3' [C:\Users\Sorin\AppData\Local\Temp\pip-install-2moej2xu\qsimcirq_2bac09547c194fe49942fe3d07d88005\build\temp.win-amd64-3.7\Release\qsim.vcxproj]
    pybind_main.cpp
  cl : command line warning D9002: ignoring unknown option '-march=native' [C:\Users\Sorin\AppData\Local\Temp\pip-install-2moej2xu\qsimcirq_2bac09547c194fe49942fe3d07d88005\build\temp.win-amd64-3.7\Release\qsim.vcxproj]
  cl : command line warning D9002: ignoring unknown option '-fopenmp' [C:\Users\Sorin\AppData\Local\Temp\pip-install-2moej2xu\qsimcirq_2bac09547c194fe49942fe3d07d88005\build\temp.win-amd64-3.7\Release\qsim.vcxproj]
  C:\Users\Sorin\AppData\Local\Temp\pip-install-2moej2xu\qsimcirq_2bac09547c194fe49942fe3d07d88005\build\temp.win-amd64-3.7\Release\_deps\pybind11-src\include\pybind11\detail/internals.h(181,1): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\Sorin\AppData\Local\Temp\pip-install-2moej2xu\qsimcirq_2bac09547c194fe49942fe3d07d88005\build\temp.win-amd64-3.7\Release\qsim.vcxproj]
  C:\Users\Sorin\AppData\Local\Temp\pip-install-2moej2xu\qsimcirq_2bac09547c194fe49942fe3d07d88005\pybind_interface\pybind_main.cpp(409,7): error C3861: 'posix_memalign': identifier not found [C:\Users\Sorin\AppData\Local\Temp\pip-install-2moej2xu\qsimcirq_2bac09547c194fe49942fe3d07d88005\build\temp.win-amd64-3.7\Release\qsim.vcxproj]
  C:\Users\Sorin\AppData\Local\Temp\pip-install-2moej2xu\qsimcirq_2bac09547c194fe49942fe3d07d88005\pybind_interface\pybind_main.cpp(461,7): error C3861: 'posix_memalign': identifier not found [C:\Users\Sorin\AppData\Local\Temp\pip-install-2moej2xu\qsimcirq_2bac09547c194fe49942fe3d07d88005\build\temp.win-amd64-3.7\Release\qsim.vcxproj]
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\Sorin\AppData\Local\Temp\pip-install-2moej2xu\qsimcirq_2bac09547c194fe49942fe3d07d88005\setup.py", line 93, in <module>
      packages=['qsimcirq'])
    File "C:\Users\Sorin\Anaconda3\envs\cirq\lib\site-packages\setuptools\__init__.py", line 153, in setup
      return distutils.core.setup(**attrs)
    File "C:\Users\Sorin\Anaconda3\envs\cirq\lib\distutils\core.py", line 148, in setup
      dist.run_commands()
    File "C:\Users\Sorin\Anaconda3\envs\cirq\lib\distutils\dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "C:\Users\Sorin\Anaconda3\envs\cirq\lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "C:\Users\Sorin\Anaconda3\envs\cirq\lib\site-packages\wheel\bdist_wheel.py", line 299, in run
      self.run_command('build')
    File "C:\Users\Sorin\Anaconda3\envs\cirq\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "C:\Users\Sorin\Anaconda3\envs\cirq\lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "C:\Users\Sorin\Anaconda3\envs\cirq\lib\distutils\command\build.py", line 135, in run
      self.run_command(cmd_name)
    File "C:\Users\Sorin\Anaconda3\envs\cirq\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "C:\Users\Sorin\Anaconda3\envs\cirq\lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "C:\Users\Sorin\AppData\Local\Temp\pip-install-2moej2xu\qsimcirq_2bac09547c194fe49942fe3d07d88005\setup.py", line 36, in run
      self.build_extension(ext)
    File "C:\Users\Sorin\AppData\Local\Temp\pip-install-2moej2xu\qsimcirq_2bac09547c194fe49942fe3d07d88005\setup.py", line 67, in build_extension
      ['cmake', '--build', '.'] + build_args, cwd=self.build_temp)
    File "C:\Users\Sorin\Anaconda3\envs\cirq\lib\subprocess.py", line 363, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--config', 'Release', '--', '/m']' returned non-zero exit status 1.
  ----------------------------------------
  ERROR: Failed building wheel for qsimcirq

(The main error is C:\Users\Sorin\AppData\Local\Temp\pip-install-2moej2xu\qsimcirq_2bac09547c194fe49942fe3d07d88005\pybind_interface\pybind_main.cpp(409,7): error C3861: 'posix_memalign': identifier not found [C:\Users\Sorin\AppData\Local\Temp\pip-install-2moej2xu\qsimcirq_2bac09547c194fe49942fe3d07d88005\build\temp.win-amd64-3.7\Release\qsim.vcxproj])

I read in the docs that installing in docker is an option. But I want to try and run some cirq circuits using this simulator and I want to do it in a jupyter notbook. Would that be possible if I install it in docker?

@95-martin-orion
Copy link
Collaborator

Hi @sorin-bolos,

Running Jupyter notebooks using a Docker image should work - it's similar to the GCP setup process, but without a separate VM.

  1. Install Docker.
  2. From the qsim directory, run docker build jupyter. This may take several minutes to complete, but in the end you should see something like Successfully built 05eeaa875462. That number is your container ID.
  3. Run docker run -p 8888:8888 ${container_ID}. This creates a Docker volume exposed to your local system, which you can navigate to from a browser. You should see output like this:
    To access the notebook, open this file in a browser:
        file:///root/.local/share/jupyter/runtime/nbserver-1-open.html
    Or copy and paste one of these URLs:
        http://a85c29a133aa:8888/?token=6c28e2f0a80d74f31a6c37df5383278b704683546bc80d8f
     or http://127.0.0.1:8888/?token=6c28e2f0a80d74f31a6c37df5383278b704683546bc80d8f
  1. Copy-paste the last URL above (the one with "127.0.0.1") into a browser. This should open a Jupyter page showing the container filesystem; you'll need to navigate to the qsim directory.
  2. In the qsim directory, create a new notebook. At the top of this notebook, add this command: !make. This may take a couple minutes - it builds the Python-C++ interface.

Once the above steps are complete, you should be able to import cirq, qsimcirq and run your circuits. Please follow up here if you run into any issues in this process.

@95-martin-orion 95-martin-orion self-assigned this Dec 30, 2020
@sorin-bolos
Copy link
Author

That worked for me, thanks!
But it would be nice if it could be called from Windows and not needing to build it from source code. Either by installing directly on Win or by having the docker container act as a server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants