Closed vlad43210 closed 6 years ago
I think you got the problem with the py-causal still calling the old jar files. Could you uninstall py-causal and make sure that there are no previous jar files (data-loader-xxx.jar and tetrad-lib-6.4.0.jar) before re-installing the v1.1.0 one?
There are two alternatives to use the current version of py-causal:
I tried the FCI example with calling the jar directly and got this error:
import javabridge
import os
import glob
import pandas as pd
import pydot
from IPython.display import SVG
#load TETRAD Libraries
tetrad_libdir = os.path.join(os.getcwd(), '../../','src', 'pycausal', 'lib')
for l in glob.glob(tetrad_libdir + os.sep + "*.jar"):
print (l)
javabridge.JARS.append(str(l))
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-78b85cb4e5a0> in <module>()
----> 1 import javabridge
2 import os
3 import glob
4 import pandas as pd
5 import pydot
/anaconda3/lib/python3.6/site-packages/javabridge/__init__.py in <module>()
36
37
---> 38 from .jutil import start_vm, kill_vm, vm, activate_awt, deactivate_awt
39
40 from .jutil import attach, detach, get_env
/anaconda3/lib/python3.6/site-packages/javabridge/jutil.py in <module>()
155 _find_jvm_mac()
156
--> 157 import javabridge._javabridge as _javabridge
158 __dead_event = threading.Event()
159 __kill = [False]
ImportError: dlopen(/anaconda3/lib/python3.6/site-packages/javabridge/_javabridge.cpython-36m-darwin.so, 2): Symbol not found: _kCFAllocatorDefault
Referenced from: /anaconda3/lib/python3.6/site-packages/javabridge/_javabridge.cpython-36m-darwin.so
Expected in: flat namespace
in /anaconda3/lib/python3.6/site-packages/javabridge/_javabridge.cpython-36m-darwin.so
Seems to me that you got the problem with installing the javabridge.
Try: pip install -U javabridge
It says I already have it. By the way, I used the anaconda install instructions.
pip install -U javabridge
Requirement already up-to-date: javabridge in /anaconda3/lib/python3.6/site-packages (1.0.17.post11+g1b38445)
Requirement already satisfied, skipping upgrade: numpy in /anaconda3/lib/python3.6/site-packages (from javabridge) (1.14.3)
Hi,
Sorry for the slow response, had to attend to other projects.
The good news is: I got it to work! The bad news I am not sure what fixed the problem, so I am still concerned. The steps I did are:
conda uninstall pycausal
and that's it... Afterwards, even more confusingly, pycausal refused to install via git / pip with this error:
Building wheels for collected packages: pycausal
Running setup.py bdist_wheel for pycausal ... error
Complete output from command /anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/bw/kk2gg7j912n0r9xg81459t1w0000gn/T/pip-req-build-fh4fqdhf/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 /private/var/folders/bw/kk2gg7j912n0r9xg81459t1w0000gn/T/pip-wheel-oizr3cua --python-tag cp36:
running bdist_wheel
running build
running build_py
creating build
creating build/lib
creating build/lib/pycausal
copying src/pycausal/pycausal.py -> build/lib/pycausal
copying src/pycausal/__init__.py -> build/lib/pycausal
copying src/pycausal/prior.py -> build/lib/pycausal
copying src/pycausal/search.py -> build/lib/pycausal
creating build/lib/pycausal/lib
copying src/pycausal/lib/causal-cmd-0.4.0-SNAPSHOT-jar-with-dependencies.jar -> build/lib/pycausal/lib
installing to build/bdist.macosx-10.7-x86_64/wheel
running install
running install_lib
creating build/bdist.macosx-10.7-x86_64
creating build/bdist.macosx-10.7-x86_64/wheel
creating build/bdist.macosx-10.7-x86_64/wheel/pycausal
copying build/lib/pycausal/pycausal.py -> build/bdist.macosx-10.7-x86_64/wheel/pycausal
copying build/lib/pycausal/__init__.py -> build/bdist.macosx-10.7-x86_64/wheel/pycausal
copying build/lib/pycausal/prior.py -> build/bdist.macosx-10.7-x86_64/wheel/pycausal
creating build/bdist.macosx-10.7-x86_64/wheel/pycausal/lib
copying build/lib/pycausal/lib/causal-cmd-0.4.0-SNAPSHOT-jar-with-dependencies.jar -> build/bdist.macosx-10.7-x86_64/wheel/pycausal/lib
copying build/lib/pycausal/search.py -> build/bdist.macosx-10.7-x86_64/wheel/pycausal
running install_data
creating build/bdist.macosx-10.7-x86_64/wheel/pycausal-1.1.0.data
creating build/bdist.macosx-10.7-x86_64/wheel/pycausal-1.1.0.data/data
warning: install_data: setup script did not provide a directory for '.' -- installing right in 'build/bdist.macosx-10.7-x86_64/wheel/pycausal-1.1.0.data/data'
error: can't copy '.': doesn't exist or not a regular file
but when I load up python, I can import pycausal
, and my code in the Jupyter notebook fully works now. Any ideas on whether / how this is actually working?
One more question: I need to assign some variables to levels in FCI, so that the algorithm does not look for irrelevant causal paths to them. Do you have any pointers for how I do that in pycausal?
Thanks so much!
Vlad
The error you got was from it tried to copy the dataset to your local library. To your FCI question, do you mean you want to assign variables to different tiers? If so, you need to create a prior knowledge like an example of runing FGES --
from pycausal import prior as p
forbid = [['TangibilityCondition','Impact']]
require =[['Sympathy','TangibilityCondition']]
tempForbid = p.ForbiddenWithin(['TangibilityCondition','Imaginability'])
temporal = [tempForbid,['Sympathy','AmountDonated'],['Impact']]
prior = p.knowledge(forbiddirect = forbid, requiredirect = require, addtemporal = temporal)
prior
Thank you! So just to be clear, the error I got for pycausal install can be avoided somehow? Should I use a particular branch (obviously, it works on my machine, but I'd like to deploy this to the cloud eventually, and I want to know how to set up the system). FWIW, the specific command I used was:
pip install git+git://github.com/bd2kccd/py-causal
Re: prior knowledge, all those commands for setting up the prior knowledge worked very well, thank you so much! I also found an example for integrating prior knowledge into the tetrad run command in one of the other algorithm notebooks in the examples folder. I seem to be all set now (aside from the above issue, which is not critical at the moment), thank you again!
Vlad
I removed data_files
parameters from setup.py and you can use pip install git+git://github.com/bd2kccd/py-causal
to deploy to the cloud without any warning. :-)
Great, thank you so much!!
Hi,
when trying to use FCI with pycausal in a Jupyter Notebook, I get the following error:
I have pycausal 1.1.0 (as far as I can tell -- I have a couple of different installations of pycausal, unfortunately, and pycausal.version does not seem to be available in the interpreter) and running this on Python 3.6.5 with JRE 1.8.0_181. This might be related to issue 58, which looks like it was fixed about a month ago, but I'm not sure if the fix made it into 1.1.0. Trying to use pycausal for a research project, and I would really appreciate your help!
Thanks,
Vlad