I am using (osx) pycharm as ide and anaconda as python (2.7.10) distribution.
Recently I have installed rpy2 which works quite well on notebook e.g.
In [5]:import rpy2.robjects as robjects
In [7]:robjects.r.pi[0]
Out[7]:3.141592653589793
But on pycharm I get a segmentation fault error.
import rpy2.robjects as robjects
/Users/xxx/anaconda/envs/analytics3/bin/python.app: line 3: 695 Segmentation fault: 11 /Users/xxx/anaconda/envs/analytics3/python.app/Contents/MacOS/python "$#"
PYcharm support claims that this is a bug in the code.
any ideas what that might be?
many thanks
Reinstalling rpy2 from
conda install -c conda.anaconda.org/rpy2
solved the issue.
If you install rpy2 via conda, and also have a system installation of R on the same machine (e.g with RStudio), the system's R installation will be used. Since this R version doesn't match the one that rpy2 needs, segmentation faults occur.
1) remove any existing system installations of R (see here). Verify that you don't have any installations of R:
$>which R
R not found
2) define R_HOME env variable, either in your .rc file:
export R_HOME=/Users/<your user>/anaconda3/envs/<env name>/lib/R
or dynamically in the python project:
import os
os.environ['R_HOME'] = '/Users/<your user>/anaconda3/envs/<env name>/lib/R'
Related
I'm trying to use JPype within ipython notebook in order to use JIDT (I don't know Java). I'm following the instructions here: https://code.google.com/p/information-dynamics-toolkit/wiki/PythonExamples.
I import jpype and start the java virtual machine with:
from jpype import *
startJVM(getDefaultJVMPath())
This makes the ipython notebook kernel crash due to the following error:
python(490,0x7fff7a99e310) malloc: *** error for object 0x104d90720: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
However, it works fine in the ipython shell.
How can I know where the error comes from and how can I fix it?
I use:
OSX 10.9.5
Python 2.7.10,Anaconda 2.2.0,IPython 3.1.0
Any help will be greatly appreciated.
I think it has to do with the C compiler used to install JPype. Try setting C compiler to clang and install JPype like this:
$env CC=clang python setup.py install
I just installed mvpa2 module on my ubuntu 14.04, Python 2.7.6. following the instruction at http://www.pymvpa.org/installation.html using sudo aptitude install python-mvpa2
Command import mvpa2 works well, but when I run from mvpa2.suite import * , I get the followin warning in my terminal:
/usr/local/lib/python2.7/dist-packages/sklearn/pls.py:7: DeprecationWarning: This module has been moved to cross_decomposition and will be removed in 0.16
"removed in 0.16", DeprecationWarning)
And also fallowing error:
TypeError: __init__() got an unexpected keyword argument 'rho'
Appreciate your help!
actually this warning comes from the import done by mdp, which PyMVPA optionally uses... you can safely ignore it (no upgrade of PyMVPA would help anyhow), because even if it gets completely removed, then mdp would simply skip that import and you would remain 'golden'.
That problem is due to an incompatibility of the python-mvpa2 and scikit-learn versions. You can check more details on that in this page, because depends on which scikit-learn version you have what will be the parameters to call a given function.
A short solution is to uninstall your python-mvpa2 and scikit-learn, and install them directly from their github repos:
[python-mvpa2] https://github.com/PyMVPA
[scikit-learn] https://github.com/scikit-learn/scikit-learn
I just did it and now the example doc/examples/som.py (for my case) is working perfectly.
this is my first stack overflow question so please pardon any ignorance about the forum on my part.
I am using python 2.7.6 64 bit and pandas 0.13.1-1 from Enthought Canopy 1.3.0.1715 on a win 7 machine. I have numpy 1.8.0-1 and numexpr 2.2.2-2.
I have inconsistent error behviour running the following on a pandas series of 10,000 numpy.float64 loaded from hdf:
import python
s = pandas.read_hdf(r'C:\test\test.h5', 'test')
s/2.
This gives me inconsistent behaviour, it sometimes works and sometimes throws:
OMP: Error #134: Cannot set thread affinity mask.
OMP: System error #87: The parameter is incorrect.
I have replicated this error on other machines, and the test case is derived from a unit test failure (with the above error) which was replicted on several machines and from a server. This has come up in an upgrade from pandas 0.12 to pandas 0.13.
The following consistantly runs with no error:
import python
s = pandas.read_hdf(r'C:\test\test.h5', 'test')
s.apply(lambda x: x/2.)
and,
import python
s = pandas.read_hdf(r'C:\test\test.h5', 'test')
pandas.computation.expressions.set_use_numexpr(False)
s/2.
Thanks for the help.
This is a very similar problem to as described in this issue, and the linked issue
It seems that only canopy is experiencing these issues. I think it has to do with the canopy numpy MKL build, but that is a guess as I have not been able to reproduce this. So here are some work-arounds:
try to upgrade numexpr to 2.4 (current version), or downgrade to 2.1
try to use numpy 1.8.1 via canopy
try to install numpy/numexpr from the posted binaries here; I don't know exactly how canopy works so not sure if this is possible
uninstall numexpr
you can also disable numexpr support via pandas.computation.expressions.set_use_numexpr(False). Note that numexpr is REQUIRED in order to read/use HDF5 files via PyTables. However the expressions disabling of numexpr should just disable it for 'computations' (and not the HDF access).
I've found a lot of posts on Macports/Django install issues but none seem to quite address my situation.
Installed Django using Macports from the command line using
sudo port install py27-django
This seemed to work fine. I opened up IDLE and was able to import django. The following bit of code
import django
from django.core import management
print django.VERSION
returns
(1, 5, 1, 'final', 0)
Which I take to mean I have the final version of Django 1.5.1 installed. So, all seems to be well.
However, now I switch over to my Django tutorial to get learning and I am asked to type this into the command line to confirm that Django is installed:
python -c "import django; print(django.get_version())"
and get the following error:
> File "<string>", line 1, in <module> ImportError: No module named
> django
Some other bits of data. Here's my $PATH:
/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin
Finally, the command
django-admin.py startproject mysite
returns
-bash: django-admin.py: command not found
But the command
django-admin-2.7.py startproject mysite
works (creates a new directory called mysite in the working directory). I read somehwere that Macports renames the django-admin file.
I've only been working with Unix for a few weeks so this is a bit confusing. It seems like I have Django on my system, but perhaps the python I am trying to access from my command line is a different python from that which Macports uses.
Any help appreciated!
Dennis
You will need to set your PYTHONPATH environment variable from your terminal to reference your django install. IDLE probably did this for you, but in another shell you'll need to set it. You can set it in your terminal permanently by setting it in ~/.bashrc or ~/.bash_profile (or whatever your terminal shell is).
Your PATH starts with /Library/Frameworks/Python.framework/Versions/2.7/bin so when you type python you get the python in that directory which is the Apple supplied one nut you have installed Django for the Macports one so python does not see it.
To fix you need to have /opt/local/bin earlier on the path than the /Library one. even better remove that /Library entry and use port select python ... to choose which python to run the Macports 2.7 or Apple's or others
As for the django-admin-2.7.py issue, Macports allows you to have several versions of python at once so code depending on eth version has the version add into the script names e.g. you could have a django-admin-2.6.py as well if you installed the py26-django package. This also applies to python itself however python also adds into the port select mechanism so you set a default version.
I'm new to Macs (and quite new to Django) and I'm setting up an existing Django/MySQL site that uses Mercurial as a site package, on a new Macbook Pro.
All was going well during installation - no error messages. I installed the default versions of most packages from macports.
However when I try runserver, localhost shows the following error message:
ImportError at /
.../lib/python2.6/site-packages/mercurial/osutil.so: no appropriate 64-bit architecture (see "man python" for running in 32-bit mode)
Please could anyone advise? I've tried typing the following at the terminal:
defaults write com.apple.versioner.python Prefer-32-Bit -bool yes
but it didn't help.
I've gotten a similar error and a combination of two things helped me install Mercurial for OS X Lion. I'm running OS X 10.7.3.
First, there is a bug on line 455 of the setup.py script (at least for Mercurial 2.2.1, the version I tried). The line
version = runcmd(['/usr/bin/xcodebuild', '-version'], {})[0].splitlines()
should be replaced with
version = runcmd(['/usr/bin/xcodebuild', '-version'], {})[0]
Second, after I installed Mercurial (either by easy_install, Mac OS X binary installer, and compilation), I kept getting the following error message:
ImportError: dlopen(/Library/Python/2.7/site-packages/mercurial/osutil.so, 2): no suitable image found. Did find: /Library/Python/2.7/site-packages/mercurial/osutil.so: mach-o, but wrong architecture
However, after seeing this post, I noticed that
defaults read com.apple.versioner.python Prefer-32-Bit
outputs 1 on my system. However, running this command
defaults write com.apple.versioner.python Prefer-32-Bit -bool no
and then recompiling / installing mercurial resulted in a working executable for me at the end.
If everything from my comment checks out, try setting that Prefer-32-bit in an user environment variable instead of at the command line.
Edit this file: ~/.MacOSX/environment.plist
See:
http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/EnvironmentVars.html#//apple_ref/doc/uid/20002093-113982