Installing compas for Blender

Hi there,

I have difficulties installing COMPAS for Blender.

I followed all the instructions from the documentation but am stuck when entering ren python original_python in anaconda, no matter what I do I always get an ‘access denied’ message and can’t proceed further in the installation.

I also tried a pip install but ran into the following error:

C:\Program Files\Blender Foundation\Blender\2.80\python\bin>python.exe -m pip install compas --user
Collecting compas
  Using cached https://files.pythonhosted.org/packages/1b/47/42a015826e4312e230db4a7d5f44ccdd353a67ddecd813ee3a166a208d0c/COMPAS-0.7.1-py2.py3-none-any.whl
Requirement already satisfied: matplotlib>=2.2; python_version >= "3.5" in c:\users\solub\appdata\roaming\python\python37\site-packages (from compas) (3.1.1)
Collecting planarity (from compas)
  Using cached https://files.pythonhosted.org/packages/91/d6/33cc8784b375a45505326e28cc01ed987e29a8091aa7c70de0c10aee7704/planarity-0.4.1.tar.gz
Requirement already satisfied: sympy in c:\users\solub\appdata\roaming\python\python37\site-packages (from
compas) (1.4)
Requirement already satisfied: numba in c:\users\solub\appdata\roaming\python\python37\site-packages (from
compas) (0.45.1)
Requirement already satisfied: cython in c:\users\solub\appdata\roaming\python\python37\site-packages (from compas) (0.29.13)
Collecting numpy==1.15.4 (from compas)
  Using cached https://files.pythonhosted.org/packages/00/0e/5a8c34adb97fc1cd6636d78050e575945e874c8516d501421d5a0f377a6c/numpy-1.15.4-cp37-none-win_amd64.whl
Requirement already satisfied: scipy>=1.0 in c:\users\solub\appdata\roaming\python\python37\site-packages (from compas) (1.3.0)
Requirement already satisfied: networkx in c:\users\solub\appdata\roaming\python\python37\site-packages (from compas) (2.3)
Requirement already satisfied: pillow in c:\users\solub\appdata\roaming\python\python37\site-packages (from compas) (6.1.0)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\solub\appdata\roaming\python\python37\site-packages (from matplotlib>=2.2; python_version >= "3.5"->compas) (1.1.0)
Requirement already satisfied: cycler>=0.10 in c:\users\solub\appdata\roaming\python\python37\site-packages (from matplotlib>=2.2; python_version >= "3.5"->compas) (0.10.0)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in c:\users\solub\appdata\roaming\python\python37\site-packages (from matplotlib>=2.2; python_version >= "3.5"->compas) (2.4.2)
Requirement already satisfied: python-dateutil>=2.1 in c:\users\solub\appdata\roaming\python\python37\site-packages (from matplotlib>=2.2; python_version >= "3.5"->compas) (2.8.0)
Requirement already satisfied: setuptools in c:\users\solub\appdata\roaming\python\python37\site-packages (from planarity->compas) (39.0.1)
Requirement already satisfied: mpmath>=0.19 in c:\users\solub\appdata\roaming\python\python37\site-packages (from sympy->compas) (1.1.0)
Requirement already satisfied: llvmlite>=0.29.0dev0 in c:\users\solub\appdata\roaming\python\python37\site-packages (from numba->compas) (0.29.0)
Requirement already satisfied: decorator>=4.3.0 in c:\users\solub\appdata\roaming\python\python37\site-packages (from networkx->compas) (4.4.0)
Requirement already satisfied: six in c:\users\solub\appdata\roaming\python\python37\site-packages (from cycler>=0.10->matplotlib>=2.2; python_version >= "3.5"->compas) (1.12.0)
Installing collected packages: planarity, numpy, compas
  Running setup.py install for planarity ... error
    ERROR: Command errored out with exit status 1:
     command: 'C:\Program Files\Blender Foundation\Blender\2.80\python\bin\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\solub\\AppData\\Local\\Temp\\pip-install-ww1kgojx\\planarity\\setup.py'"'"'; __file__='"'"'C:\\Users\\solub\\AppData\\Local\\Temp\\pip-install-ww1kgojx\\planarity\\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\solub\AppData\Local\Temp\pip-record-37060ik9\install-record.txt' --single-version-externally-managed --compile --user
--prefix=
         cwd: C:\Users\solub\AppData\Local\Temp\pip-install-ww1kgojx\planarity\
    Complete output (27 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.7
    creating build\lib.win-amd64-3.7\planarity
    copying planarity\planarity_functions.py -> build\lib.win-amd64-3.7\planarity
    copying planarity\planarity_networkx.py -> build\lib.win-amd64-3.7\planarity
    copying planarity\__init__.py -> build\lib.win-amd64-3.7\planarity
    creating build\lib.win-amd64-3.7\planarity\tests
    copying planarity\tests\test.py -> build\lib.win-amd64-3.7\planarity\tests
    copying planarity\tests\test_planarity.py -> build\lib.win-amd64-3.7\planarity\tests
    copying planarity\tests\test_planarity_networkx.py -> build\lib.win-amd64-3.7\planarity\tests
    copying planarity\tests\__init__.py -> build\lib.win-amd64-3.7\planarity\tests
    running build_ext
    cythoning planarity/planarity.pyx to planarity\planarity.c
    C:\Users\solub\AppData\Roaming\Python\Python37\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\Users\solub\AppData\Local\Temp\pip-install-ww1kgojx\planarity\planarity\planarity.pyx
      tree = Parsing.p_module(s, pxd, full_module_name)
    building 'planarity.planarity' extension
    creating build\temp.win-amd64-3.7
    creating build\temp.win-amd64-3.7\Release
    creating build\temp.win-amd64-3.7\Release\planarity
    creating build\temp.win-amd64-3.7\Release\planarity\src
    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.21.27702\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -Iplanarity/src/ "-IC:\Program Files\Blender Foundation\Blender\2.80\python\include" "-IC:\Program Files\Blender Foundation\Blender\2.80\python\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.21.27702\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt" /Tcplanarity\planarity.c /Fobuild\temp.win-amd64-3.7\Release\planarity\planarity.obj
    planarity.c
    planarity\planarity.c(4): fatal error C1083: Impossible d'ouvrir le fichier includeÿ: 'Python.h'ÿ: No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.21.27702\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Program Files\Blender Foundation\Blender\2.80\python\bin\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\solub\\AppData\\Local\\Temp\\pip-install-ww1kgojx\\planarity\\setup.py'"'"'; __file__='"'"'C:\\Users\\solub\\AppData\\Local\\Temp\\pip-install-ww1kgojx\\planarity\\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\solub\AppData\Local\Temp\pip-record-37060ik9\install-record.txt' --single-version-externally-managed --compile --user --prefix= Check the logs for full command output.

Another thing I’ve noticed is that whenever I try to install a module with:

C:\Program Files\Blender Foundation\Blender\2.80\python\bin>python.exe -m pip install modulename --user

… that module doesn’t appear in the site-packages folder of the Blender’s Python.
I’m suspecting a conflict between the different Python installations on my system but have no clue how to fix this.

I pretty much spent the whole day on this but to no avail. Any help would be greatly appreciated.

hi,

will do my best to help out. first a few questions so i better understand what is going on…

  1. where did you “install” Blender?

  2. the “access denied” error might be due to limited rights of your account. have you tried running Anaconda Prompt as administrator when following the procedure in the docs?

  3. did you install COMPAS using conda?

  4. did you install COMPAS in a separate environment? was that environment active when you replaced the Blender Python?

the rest of the instructions in the docs only make sense after you have replaced the Blender Python with the Python in the environment for which you installed COMPAS. this might be the base environment but i would recommend making a specific environment for Blender.

i also noticed that the docs suggest using the Command Prompt for the replacing. this might not work because the %CONDA_PREFIX% variable might not be available. use the Anaconda Prompt instead.

once Blender Python is replaced you can just install packages in the relevant conda Python environment using the Anaconda Prompt. no need to specify the path to Blender Python. Blender will use the Python and installed packages of your environment. not the other way around.

anyway, if you have a working version of COMPAS in a conda environment with Python 3.7, i have the feeling steps 1 and 2 will already solve the problem. just make sure to use Anaconda Prompt, run it as a administrator, and have the correct conda environment active while you issue the commands from the docs.

let me know if this doesn’t work…

tom

1 Like

Hi @tomvanmele ,

Apologies for the late reply (very busy on week days) and thank you for your suggestions, I really appreciate your help.

Trying to answer your questions:

1/ Blender is installed here:

C:\Program Files\Blender Foundation\Blender

2/ At first, the “access denied” appeared even logged as an administrator but after rebooting my machine it finally worked (don’t really know why).

3/ Yes, I did install COMPAS using conda (basically following the instructions from the official page)

Now the problem is I have the following error when importing the COMPAS module from Blender:

ValueError: failed to parse CPython sys.version: '3.7.0'

I still suspect a conflict between the different Python installations on my system and believe I have to change something in the environment variables but don’t know what exactely.

Details

---- the error:

 File "C:\Users\solub\AppData\Roaming\Python\Python37\site-packages\numpy\core\_internal.py", line 20, in <module>
    IS_PYPY = platform.python_implementation() == 'PyPy'
  File "C:\Program Files\Blender Foundation\Blender\2.80\python\lib\platform.py", line 1265, in python_implementation
    return _sys_version()[0]
  File "C:\Program Files\Blender Foundation\Blender\2.80\python\lib\platform.py", line 1226, in _sys_version
    repr(sys_version))
ValueError: failed to parse CPython sys.version: '3.7.0 (default, Aug 26 2018, 16:05:01) [MSC v.1900 64 bit (AMD64)]'

---- the absolute path of locations of python:

    (base) C:\Users\solub> where python
    C:\Users\solub\python
    C:\Users\solub\python.exe
    C:\Users\solub\Anaconda2\python.exe

---- path environment variables

hi,

i see you are using Anaconda2. this is not a problem in itself, but you have to make sure that the conda environment you create for Blender runs on Python 3.7. otherwise Blender will not accept this as a proper replacement of its own Python.

make sure to make a separate conda environment for the Blender replacement.

conda config --add channels conda-forge
conda create -n blender python=3.7 COMPAS

and make sure the blender environment is active when you replace the Blender Python.

conda activate blender

also make sure that Blender is not running when you do this.

cd %PROGRAMFILES%\Blender Foundation\Blender\2.80
ren python original_python
mklink /j python %CONDA_PREFIX%

from this point on you can install new packages for Blender Python by installing new packages into the blender environment using the Anaconda Prompt. no need to re-install anything in Blender. the next time you start Blender the packages will be available.

as for your many Python installs.
do you really need those?
if you use Anaconda it will be a lot easier if you use it all the way.
it allows you to make as many environments as you like with both Python 2 and Python 3.
so there is no need to have additional Python installs lingering around.

also, recent versions of Anaconda recommend not to register it on the PATH and to just use the Anaconda Prompt instead of the Command Prompt. this tends to make life a bit easier indeed, in my experience…

1 Like

Thank you so much for your help.

I uninstalled Anaconda2 and its environments and installed Anaconda3 instead. It works now !