Problem importing a specific library with python 2.7.10 - python

I am trying to install the following package in my MacOS High Sierra 10.13.6:
https://github.com/Michalychforever/CLASS-PT
When i run the make file everything looks to work fine. It not only generate an executable, which i can run by terminal using the ./ command, but also a python wrapper. The problem is related only with the former.
When i try to import the library i get the following message:
import classy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/Users/thiagomergulhao/Library/Python/2.7/lib/python/site-packages/classy.so, 2): Symbol not found: _zdotu_
Referenced from: /Users/thiagomergulhao/Library/Python/2.7/lib/python/site-packages/classy.so
Expected in: flat namespace
in /Users/thiagomergulhao/Library/Python/2.7/lib/python/site-packages/classy.so
I am using the built-in python version (i.e 2.7.10). I already installed the Xcode 10.1 together with command line commands. My .bash_profile is:
export PATH="/Users/thiagomergulhao/Library/Python/2.7/bin:$PATH"
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
Does anyone have any ideia what is causing this problem?

Related

Problem using installed packages with PIP (possibly due to two Python versions)

When I try to use installed packages in Python, I nearly always run into the same error.
So I e.g. install a package like this: pip3 install mathplot and when I afterwards want to use it in Python3 (I use python3 in the command prompt), I run into the ModuleNotFoundError:
>>> import mathplot
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'mathplot'
But when I run just python, the module is found and ready to use.
Any idea where this problem comes from and how I can get rid of it?
Thanks in advance

paraview-python: Could not import vtkCommonComputationalGeometry

I try to run a python script (test.py) containing this line only:
from paraview.simple import *
I want to use the last version of paraview. So, I downloaded it from the official webpage and I uncompressed the corresponding archive into a folder, say /home/paraview.
If I do not anything more than running the script with
python test.py
I get the following error message:
Traceback (most recent call last):
File "test.py", line 2, in <module>
from paraview.simple import *
ModuleNotFoundError: No module named 'paraview'
So, I set my PYTHONPATH like this:
export PYTHONPATH=/home/paraview/lib/python2.7/site-packages:$PYTHONPATH
Then, I rerun my script and I get a different error message:
Error: Could not import vtkCommonComputationalGeometry
Segmentation fault
I tried to set LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=/home/paraview/lib
where vtkCommonComputationalGeometry.so is but it does not work.
Furthermore, if I try to locate vtkCommonComputationalGeometry, I find it in another location:
/usr/lib/x86_64-linux-gnu/libvtkCommonComputationalGeometry-6.2.so
I removed vtk with apt but it is still here.
Do you know how I could run my script?
Just use pvpython, that can be found in ParaView binaries.
path/to/ParaView/bin/pvpython test.py
try to install PVGeo package.
pip install PVGeo

Custom python install location: tkinter problems

I'm using Ubuntu 14.04. While I have to retain my "main" python install as 2.7.6, I need to install 2.7.9 to be able to use ssl.SSLContext, to get Flask to deal with HTTPS requests.
However, if I just do:
sudo make install
or
sudo make altinstall
in the Python-2.7.9 directory, I ultimately get:
make: *** [libinstall] Error 1
EDIT: this appears at the end of sudo make install:
...
Compiling /usr/local/lib/python2.7/xml/sax/saxutils.py ...
Compiling /usr/local/lib/python2.7/xml/sax/xmlreader.py ...
Compiling /usr/local/lib/python2.7/xmllib.py ...
Compiling /usr/local/lib/python2.7/xmlrpclib.py ...
Compiling /usr/local/lib/python2.7/zipfile.py ...
make: *** [libinstall] Error 1
So I installed it to a custom directory by modifying the call to ./config, which did not yield the libinstall error.
However, when I try to import Tkinter into Python 2.7.9 (running from the custom directory) I obtain:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/repos/Python279/lib/python2.7/lib-tk/Tkinter.py", line 39, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
If I just go ahead and install the vanilla way (i.e., to a non-custom directory) and simply ignore the libinstall error I get, upon importing Tkinter:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/lib-tk/Tkinter.py", line 39, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: /usr/lib/python2.7/lib-dynload/_tkinter.so: undefined symbol: PyFPE_jbuf
Does anyone have any idea what is going on?
Following furas' suggestion, installing via the
Python 2.7 PPA maintained be Felix Krull worked spectacularly. Thanks Furas!
EDIT Some notes:
Because this PPA installs python2.7 (specifically v. 2.7.11, as of 1/29/2016), this obviated the need for a custom python install location
While the PPA website mentions that this doesn't include python-tk, provided you have installed it, python plays with it just fine (solving my problem)
First of all source code from a program must be configured, compiled, then installed. You can do this by:
./configure # Or ./config depending on the file name
make
make install
Second of all when you tried to import the module _tkinter you wanted to import the .py file which was called Tkinter.py
Try to use:
import Tkinter

Python ImportError NetCDF4

I've been using Python to treat some data that is in netcdf format... Usually I type the code within Pycharm a Python IDE, which I've configure to run the Python scripts with the system install.
To read the .nc files I use the NetCDF4 package and I've no problem when running within Pycharm. However, when I try to run the same script but from the system command line I always got the following error:
Traceback (most recent call last):
File "CheckDate.py", line 2, in <module>
import netCDF4 as n4
ImportError: /usr/local/lib/python2.7/dist-packages/netCDF4.so: undefined symbol: nc_inq_var_endian
Can anybody give me some help to fix this?

Import vim in python gives back errors

I read some articles about Vimscripting with python. I felt very interested. So I tried to figure out how to do vimscripting with python.
But when I tried to import vim, it showed that the module vim wasn't installed. So I searched
on the web, but still haven't find the module to install.
I also tried pip to search automatically, still failed.
Does anyone know where to find the module vim?
I am using fedora 17, and I have installed vim 7.3 and python 2.7.
Thanks in advance.
Here is the error message:
>>> import vim
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named vim
It doesn't seem like you need to import it, just make sure your vim is compiled with python support. Check this using vim --version | grep +python. Further, it seems that the vim module is imported automatically when in vim, rendering your import line unnecessary.
it do not work but this will work
:python from vim import *
:python command('echo "Hello World!"')
if you put vim.command(..
You get
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'vim' is not defined
Compile VI with python as described by hd1. You can find the documentation here:
http://vimdoc.sourceforge.net/htmldoc/if_pyth.html
If you want to test
export PYTHONPATH=$HOME/local/lib/python2.7/site-packages
Note that I installed all in local, this is why I use $HOME in PYTHONPATH
Run vi then, type
:python from vim import *
:python vim.command('echo "Hello World!"')
you should see "Hello World!" below.

Categories

Resources