pythoninstallationimportpipsite-packages

With Python 3 I get a pip error when importing the 'noise' package by Caseman, anyone know a fix for it?


I'm writing a (really janky) 2d fluid simulation in Python. Currently I'm generating a starting state for the sim by just filling a 2d array with random floats generated by the random module, and then blurring the texture by averaging each cell with the ones around it. This is very slow, and produces a noise texture that's somewhat blocky due to the square blur shape. So once I got bored of waiting for ten seconds every now and then for python to generate a new random grid, I decided to invest what I thought would be a mere ten minutes into figuring out how to use a library for it. Five hours later, I find myself exactly where I started, just more frustrated. I've been trying to install this package using the command pip install noise, but every time I try the command the same error comes back, even after trying every other fix for similar problems I could find. The error looks like this:

Defaulting to user installation because normal site-packages is not writeable
Collecting noise
  Using cached noise-1.2.2.zip (132 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: noise
  Building wheel for noise (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [31 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win32-cpython-312
      creating build\lib.win32-cpython-312\noise
      copying perlin.py -> build\lib.win32-cpython-312\noise
      copying shader.py -> build\lib.win32-cpython-312\noise
      copying shader_noise.py -> build\lib.win32-cpython-312\noise
      copying test.py -> build\lib.win32-cpython-312\noise
      copying __init__.py -> build\lib.win32-cpython-312\noise
      running build_ext
      building 'noise._simplex' extension
      creating build\temp.win32-cpython-312
      creating build\temp.win32-cpython-312\Release
      "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\bin\HostX86\x86\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD "-IC:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1008.0_x64__qbz5n2kfra8p0\include" "-IC:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1008.0_x64__qbz5n2kfra8p0\Include" "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\cppwinrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\cppwinrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" /Tc_simplex.c /Fobuild\temp.win32-cpython-312\Release\_simplex.obj
      _simplex.c
      _simplex.c(235): warning C4244: 'return': conversion from 'double' to 'float', possible loss of data
      _simplex.c(296): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
      _simplex.c(297): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
      _simplex.c(308): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
      _simplex.c(309): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
      "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\bin\HostX86\x86\link.exe" /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO "/LIBPATH:C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1008.0_x64__qbz5n2kfra8p0\libs" "/LIBPATH:C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1008.0_x64__qbz5n2kfra8p0" "/LIBPATH:C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.1008.0_x64__qbz5n2kfra8p0\PCbuild\win32" "/LIBPATH:C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\lib\x86" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x86" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\ucrt\x86" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\\lib\10.0.22000.0\\um\x86" "/LIBPATH:C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\lib\x86" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x86" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\ucrt\x86" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\\lib\10.0.22000.0\\um\x86" /EXPORT:PyInit__simplex build\temp.win32-cpython-312\Release\_simplex.obj /OUT:build\lib.win32-cpython-312\noise\_simplex.cp312-win_amd64.pyd /IMPLIB:build\temp.win32-cpython-312\Release\_simplex.cp312-win_amd64.lib
         Creating library build\temp.win32-cpython-312\Release\_simplex.cp312-win_amd64.lib and object build\temp.win32-cpython-312\Release\_simplex.cp312-win_amd64.exp
      _simplex.obj : error LNK2001: unresolved external symbol __imp__PyFloat_FromDouble
      _simplex.obj : error LNK2001: unresolved external symbol __imp__PyErr_SetString
      _simplex.obj : error LNK2001: unresolved external symbol __imp__PyExc_ValueError
      _simplex.obj : error LNK2001: unresolved external symbol __imp__PyModule_Create2
      _simplex.obj : error LNK2001: unresolved external symbol __imp__PyArg_ParseTupleAndKeywords
      build\lib.win32-cpython-312\noise\_simplex.cp312-win_amd64.pyd : fatal error LNK1120: 5 unresolved externals
      error: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.36.32532\\bin\\HostX86\\x86\\link.exe' failed with exit code 1120
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for noise
  Running setup.py clean for noise
Failed to build noise
ERROR: Could not build wheels for noise, which is required to install pyproject.toml-based projects

I've tried updating wheel, setuptools, Cmake, pip, Python, and even PowerShell to no avail. I've added all the python-related dirs to PATH as well. Nothing has worked, I still get the same error.


Solution

  • The package you are trying to install contains C code and thus needs to be compiled.

    You have an issue with your toolchain though:

    You are using a x86 compiler/linker, see HostX86\x86\cl.exe and ...HostX86\x86\link.exe - make sure that you have a 64 bit python and that you execute C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat before attempting your pip install

    Apart from that, you might have compatibility issues:

    The library you are trying to install was last updated in 2015. It looks to me like the missing symbols should be present in python 3.12 as well, but no guarantee that installing to this python version will work without issue. If, after making sure you are compiling for x64 you still have issues, try to downgrade python to a lower version