Compas installation probelm in conda

hi,
Long-story short, after I realized I was missing out some functionalities, I decided to upgrade my compas to version 0.15.5 (previously, I had 0.14). Then there was a longer story (a vicious cycle actually) that if I installed the latest version of compas I could not run numpy (error #1) and if I installed numpy version 1.18 and scipy first then I could not install the latest version of compas (error#2) due to incompatibilities. I have been following the installation guidelines provided here.
I have to add that due to these problems I have uninstalled and reinstalled Anaconda and miniconda already 3 times (now working with anaconda).
I would appreciate any tip on how to fix this issue.

error #1

Blockquote

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy c-extensions failed.

  • Try uninstalling and reinstalling numpy.

  • If you have already done that, then:

    1. Check that you expected to use Python3.7 from “C:\Users\pnourian\Anaconda3\envs\genesis\python.exe”,
      and that you have no directories in your PATH or PYTHONPATH that can
      interfere with the Python and numpy version “1.18.1” you’re trying to use.
    2. If (1) looks fine, you can open a new issue at
      Issues · numpy/numpy · GitHub. Please include details on:
      • how you installed Python
      • how you installed numpy
      • your operating system
      • whether or not you have multiple versions of Python installed
      • if you built from source, your compiler versions and ideally a build log
  • If you’re working with a numpy git repository, try git clean -xdf
    (removes all files not under version control) and rebuild numpy.

Note: this error has many possible causes, so please don’t comment on
an existing issue about this - open a new one instead.

Original error was: DLL load failed: The specified module could not be found.

Blockquote

error#2:

Blockquote
active environment : genesis
active env location : C:\Users\pnourian\Anaconda3\envs\genesis
shell level : 2
user config file : C:\Users\pnourian.condarc
populated config files : C:\Users\pnourian.condarc
conda version : 4.8.2
conda-build version : 3.18.11
python version : 3.7.6.final.0
virtual packages : __cuda=10.0
base environment : C:\Users\pnourian\Anaconda3 (writable)
channel URLs : main/win-64
main/noarch
r/win-64
r/noarch
msys2/win-64
msys2/noarch
conda-forge/win-64
conda-forge/noarch
package cache : C:\Users\pnourian\Anaconda3\pkgs
C:\Users\pnourian.conda\pkgs
C:\Users\pnourian\AppData\Local\conda\conda\pkgs
envs directories : C:\Users\pnourian\Anaconda3\envs
C:\Users\pnourian.conda\envs
C:\Users\pnourian\AppData\Local\conda\conda\envs
platform : win-64
user-agent : conda/4.8.2 requests/2.22.0 CPython/3.7.6 Windows/10 Windows/10.0.17763
administrator : False
netrc file : None
offline mode : False
An unexpected error has occurred. Conda has prepared the above report.
If submitted, this report will be used by core maintainers to improve
future releases of conda.
Would you like conda to send this report to the core maintainers?
Blockquote

hi,

there is no difference between the versions of packages required by COMPAS 0.14.x and COMPAS 0.15.x so something else must have gone wrong…

it seems weird that it was not possible to upgrade COMPAS after upgrading numpy/scipy since COMPAS only requires their respective versions to be higher than 1.15.4 and 1.1.

it might be that the very latest versions of numpy/scipy are not properly supported yet in the conda ecosystem… i have 1.17.3 and 1.2.1

anyway before i try to suggest potential solutions, could you provide info about the following:

  • do you have other versions of Python installed?
  • is Anaconda on your PATH?
  • is miniconda still on your PATH?
  • what is in your .condarc?
  • have you restarted your computer after uninstalling/reinstalling Anaconda?
  • where did the error about the DLL’s occur after you first upgraded COMPAS (for example, Terminal/Prompt, VS Code, Rhino, …)?
  • how did you upgrade COMPAS? (pip, conda, …)
  • how did you upgrade numpy?

Hi, thanks for your meticulous investigation! Please see below my responses to your questions:
do you have other versions of Python installed?

Yes, in addition to the py37 of conda I have one py27 for Rhino and one for Houdini; but none of these two are managed by my conda.

is Anaconda on your PATH?

is miniconda still on your PATH?

Yes when I echo %PATH% on the command prompt I get the following items pertaining to anaconda, but nothing pertaining to the [potential remainders of] miniconda

C:\Users\pnourian>echo %PATH%

C:\Users\pnourian\Anaconda3\condabin;

C:\Users\pnourian\Anaconda3;

C:\Users\pnourian\Anaconda3\Library\mingw-w64\bin;

C:\Users\pnourian\Anaconda3\Library\usr\bin;C:\Users\pnourian\Anaconda3\Library\bin;C:\Users\pnourian\Anaconda3\Scripts;

what is in your .condarc?

If you mean the .condarc file, I can open it with atom and see this content:

ssl_verify: true

channels:

  • conda-forge

  • defaults

channel_priority: strict

When I search my computer for condarc I see a couple of other files with this name, one of which named condarc (without the dot) is located in the anaconda directory. It contains the following (after the responses to other questions).

have you restarted your computer after uninstalling/reinstalling Anaconda?

Yes, several times, I cannot be sure about every time this happened but I did these in multiple days starting from about three weeks ago, always hitting the same wall before and after installing anaconda. However, I must say I might have not restarted my computer immediately after every installation of anaconda.

where did the error about the DLL’s occur after you first upgraded COMPAS (for example, Terminal/Prompt, VS Code, Rhino, …)?

Mostly in anaconda prompt and also in VS Code

how did you upgrade COMPAS? (pip, conda, …)

almost always using conda, maybe once using pip too, but I don’t recall that specifically. I might have tried installing one of the dependencies using pip though, which I do not recall unfortunately. In any case, I have not used pip in my latest installation for sure.

how did you upgrade numpy?

I have used the command “conda update numpy” in Anaconda Prompt; which failed whenever I had compas installed beforehand.
indent preformatted text by 4 spaces

This is a sample .condarc file

channel locations. These override conda defaults, i.e., conda will

search only the channels listed here, in the order given. Use “defaults” to

automatically include all default channels. Non-url channels will be

interpreted as binstar usernames (this can be changed by modifying the

channel_alias key; see below).

channels:

Alias to use for non-url channels used with the -c flag. Default is https://conda.binstar.org/

channel_alias: https://your.repo/

Proxy settings: http://[username]:[password]@[server]:[port]

proxy_servers:
http: http://user:pass@corp.com:8080
https: https://user:pass@corp.com:8080

directory in which conda root is located (used by conda init)

root_dir: ~/.local/conda_root

directories in which environments are located

envs_dirs:

  • ~/my-envs
  • /opt/anaconda/envs

directories in which package cache can be present

pkgs_dirs:

  • ~/my-pkgs
  • /opt/anaconda/pkgs

implies always using the --yes option whenever asked to proceed

always_yes: True

disallow soft-linking (default is allow_softlinks: True,

i.e. soft-link when possible)

allow_softlinks: False

always use soft-links instead of hard-links (default False)

always_softlink: True

change ps1 when using activate (default True)

changeps1: False

use pip when installing and listing packages (default True)

use_pip: False

binstar.org upload (not defined here means ask)

binstar_upload: True

when creating new environments add these packages by default

create_default_packages:

  • python
  • pip

disallowed specification names

disallow:

  • anaconda

enable certain features to be tracked by default

track_features:

  • mkl
    indent preformatted text by 4 spaces

about the multiple Python versions:

  • the py27 for Rhino is because you are using Rhino5? so it is an IronPython install?
  • any particular reason you also have a separate Python install for Houdini?

one of the reasons to put Python on your PATH would be because you need access to it from the command line. if that is not necessary for you, i would consider removing them.

the recommended way to install Anaconda is also to not register it on PATH and basically use the Anaconda Prompt whenever you want to work with the (Ana)conda ecosystem from the command line.

none this explains the problems you are having though.

one of the things that stands out to me in your explanation is that you can’t update numpy if COMPAS is already installed. note that the command conda update numpy may not work as you expect it. for whatever reason it does not necessarily try to upgrade the package in question to the most recent version. probably the command fails because COMPAS has minimum requirements set for numpy and the update command tries to set it to a version lower than that. if you know which version you want to install do conda install numpy=1.17.3, for example.

if the DLL thing happens in VS Code, make sure that you are not trying to run scripts using the PowerShell. again for some weird reason, this is the default in VS Code if the PowerShell is present even though this simply doesn’t work. to change this, delete all the shell instances that are already registered (if you right-click in a Python file and select “Run Current File in Terminal” a shell window opens on the bottom. click the trash can repeatedly to remove all those instances.) and use the command palette to find “Terminal: Select Default Shell”. this will allow you to select the Command Prompt instead of the PowerShell.

it could be that simply making a new environment and installing COMPAS combined with the shell change in VS Code solves you problems, if the order in which stuff started to go wrong was the following:

  1. you installed COMPAS
  2. you tried running something in VS Code and ran into the DLL problem
  3. because of 2 you tried upgrading numpy in the COMPAS environment, but this didn’t work because of the update thing i tried to explain
  4. you then tried fixing things here and there but it only got worse :slight_smile:

i might also be completely wrong and then we will have to look for a different solution…

1 Like

Thanks for the tips, especially about VS code. There was indeed something strange about it, which seems to have been corrected (but I would not know how to check that). I cleaned my whole machine from all traces of Python and conda; uninstalled anaconda properly using these instructions; echoed path from windows cmd; found old paths from my old miniconda; removed them by hand by going to “edit system environment variables for your account”; echoed the path again and found it clean; found an old python 27 unrelated to IronPython of Rhino and deleted it; removed Houdini and its python instance; reinstalled miniconda; installed numpy (1.18.1) and scipy (1.4.1) and compas (=0.15.5). I checked numpy, scipy and compas installations in anaconda prompt by running python from there and checked the versions; everything seemed normal. However, when I tried to run some code in VS Code including numpy and compas it gave me that notorious error again:

ps. I just ran these lines:

Blockquote

import numpy as np

import pandas as pd

import compas

Blockquote

Blockquote

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy c-extensions failed.

  • Try uninstalling and reinstalling numpy.
  • If you have already done that, then:
    1. Check that you expected to use Python3.7 from “C:\Users\pnourian\Miniconda3\python.exe”,
      and that you have no directories in your PATH or PYTHONPATH that can
      interfere with the Python and numpy version “1.18.1” you’re trying to use.
    2. If (1) looks fine, you can open a new issue at
      Issues · numpy/numpy · GitHub. Please include details on:
      • how you installed Python
      • how you installed numpy
      • your operating system
      • whether or not you have multiple versions of Python installed
      • if you built from source, your compiler versions and ideally a build log
  • If you’re working with a numpy git repository, try git clean -xdf
    (removes all files not under version control) and rebuild numpy.
    Note: this error has many possible causes, so please don’t comment on
    an existing issue about this - open a new one instead.
    Original error was: DLL load failed: The specified module could not be found.

Blockquote

Is COMPAS 0.15.5 incompatible with numpy 1.18.1 and scipy 1.4.1?

ps. just had a gut feeling that this may have to do with vs code, and gave it a try with Jupyter Notebook (re installed it on miniconda) then it turned out that the error does not appear in jupyter. Conclusion, this is an issue with VS Code. Would you suggest to reinstall vs code or do you happen to have another magic fix :slight_smile:

no. :slight_smile:

just to make sure, run the following using Python in the Anaconda Prompt

>>> import compas
>>> from compas.datastructures import Mesh
>>> from compas.datastructures import mesh_connectivity_matrix
>>> mesh = Mesh.from_obj(compas.get('faces.obj'))
>>> mesh_connectivity_matrix(mesh)
array([[-1.,  1.,  0., ...,  0.,  0.,  0.],
       [-1.,  0.,  0., ...,  0.,  0.,  0.],
       [ 0., -1.,  0., ...,  0.,  0.,  0.],
       ...,
       [ 0.,  0.,  0., ...,  1.,  0.,  0.],
       [ 0.,  0.,  0., ..., -1.,  1.,  0.],
       [ 0.,  0.,  0., ...,  0., -1.,  1.]])
>>> 

if that works, and if the only place stuff goes wrong is VS Code, then in my experience it is always related to this PowerShell thing. can you confirm that scripts are being run using Command Prompt and not PowerShell?

that being said, not so long ago there was another person having problems with VS Code and he seemed to think it had something to do with his regular Visual Studio installation.

anyway, if the problem is not the PowerShell thing, reinstalling VS Code is worth giving a shot.

btw, just out of curiosity (that is the only other thing it could potentially be, although it would be surprising) any particular reason you are using miniconda?

1 Like

Hi,

Indeed it turned out to be a problem within VS code on a windows system as you had guessed. I have the same setup on a mac and it is working. Thanks to your hint and another hint from a colleague (Shervin) I found this fix for VS code to change the default Windows Power Shell with Anaconda Prompt (after having uninstalled and reinstalled VS code as you suggested). Everything seems to be working now. I share the fix for people who might encounter the same problem in future.

ps. I chose to continue with miniconda simply because I wanted to save space on my clunky system :). Any downside w.r.t. usage of compas?

no not at all. was just curious. might start working with miniconda for some projects myself…

glad that it all works now.
have fun!

1 Like