not able to install netCDF4 in python without HDF5 - python

i have been trying to install the python package for netcdf4 using the package provided in
ftp://ftp.unidata.ucar.edu/pub/netcdf/
i have installed the netcdf-4.3.3.1.zip
extracted it and followed the instructions given in
https://www.unidata.ucar.edu/software/netcdf/docs/netcdf-install/Quick-Instructions.html
2.1 Building NetCDF Without HDF5
If you don't want netCDF-4/HDF5, then build like this:
./configure --prefix=/home/ed/local --disable-netcdf-4
make check install
(Replace “/home/ed/local” with the name of the directory where netCDF is to be installed.)
i replaced '/home/ed/local' with '/usr/lib/python2.7/dist-packages'
after this i ran the command ' nc-config --version'
netCDF 4.3.3.1
but i am not able to import the module in python i am geting that
ImportError: No module named netCDF4
nor i am able to find any folder related to netcdf4 in /usr/lib/python2.7/dist-packages
i just need to read the .nc file data if their is any other way help me
thank you
EDIT -------
i realised that you require hdf5 so i got the package
then when i follow the instructions given in the link
when i run the instructions for hdf5 folder i got some errors related to conversion of dos files to unix i fixed them by saving them with ending in unix/linux . but i did not do all the files as after the first two files there where no errors
then i use the commands
make
sudo make install
i get multiple output as
make[1]: Entering directory `/home/akhil/hdf5-1.8.16/src'
Makefile:972: .deps/H5.Plo: No such file or directory
Makefile:973: .deps/H5A.Plo: No such file or directory
Makefile:974: .deps/H5AC.Plo: No such file or directory
Makefile:975: .deps/H5Abtree2.Plo: No such file or directory
Makefile:976: .deps/H5Adense.Plo: No such file or directory
and many errors of the same format
so i ignore them since there was no specific error
igo do the commands for netdf4 file
once i do the first command
LDFLAGS=-L/usr/local/lib CPPFLAGS=-I/usr/local/include ./configure -- enable-netcdf-4 --enable-dap --enable-shared --prefix=/usr/local
i get an error
configure: error: Can't find or link to the hdf5 library. Use --disable-netcdf-4, or see config.log for errors.
then i go into the netcdf4 python
i run sudo python setup.py install
error
netCDF4/_netCDF4.c:237:22: fatal error: H5public.h: No such file or directory
#include "H5public.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
help

Related

Cant import local module

So I am trying to use this repository on my computer but I cant seem to import a local module (Agent.pyx) and use functions from that file. The error I get is:
ModuleNotFoundError: No module named 'RLAgent.Agent
Screenshot of error
Link to repository
You have to install the package manually
Since Agent.pyx is a .pyx file, you will need to first build it. The README file in the linked repo also mentions this. So you need to move to the RLAgent directory and execute the setup instruction as:
cd RLAgent
python3 setup.py build_ext --inplace
This will build the required .c and .so file which will then enable it's import in other files such as Train.py which is where the import is throwing an error.

How do I run a setup.py file without being in its directory?

To install a package that includes a setup.py file, usually you cd into the root directory where setup.py is located and then run the following:
python setup.py install
Now my problem is that I'm building an addon for another application, and while I can install "normal" package via code with the following:
subprocess.run([sys.executable, "-m", "pip", "install", package])
I also have to install a couple custom made packages, and if I try to do it like this:
subprocess.run([sys.executable, "-m", "/MSN-Point-Cloud-Completion-master/emd/setup.py", "install"])
I get the following error: Error while finding module specification for 'MSN-Point-Cloud-Completion-master/emd/setup.py' (ModuleNotFoundError: No module named 'MSN-Point-Cloud-Completion-master/emd/setup')
What is annoying me is that if I manually cd into the directory and simply run python setup.py install from the cmd it works just fine.
So the problem seems to be passing the relative path to the setup.py file, but as I said, considering this is an addon I need to install that setup.py from code. Any solution?
Reading comments made me realize a few mistakes.
First of all I realized that I shouldn't use -m flag in this case and this allow me to execute setup.py correctly. Also deleted the extra slash in the path and now the following works:
subprocess.run([sys.executable, "MSN-Point-Cloud-Completion-master/emd/setup.py", "install"])
However, since I wasn't in that directory still, I also got the following error c1xx: fatal error C1083: It is not possible to open file: 'emd_cuda.cu': No such file or directory and the compilation failed.
This definitely fixed all the problems:
import os
import subprocess
os.chdir("MSN-Point-Cloud-Completion-master/emd/")
subprocess.run([sys.executable, "setup.py", "install"])

Mac OS X error: directory that is not on PYTHONPATH and which Python does not read ".pth" files from

I'm getting an error while trying to install FEnicS on Mac OS X 10.11.6. I've read the responses to similar questions on this website, and have tried the suggested solutions, but I must be doing something wrong.
On running the command:
curl -s https://fenicsproject.org/fenics-install.sh | bash
I get an error while the cython package is being installed:
[cython] Building cython/e2t4ieqlgjl3, follow log with:
[cython] tail -f /Users/sophiaw/.hashdist/tmp/cython-e2t4ieqlgjl3-1/_hashdist/build.log
[cython|ERROR] Command '[u'/bin/bash', '_hashdist/build.sh']' returned non-zero exit status 1
[cython|ERROR] command failed (code=1); raising.
The message from build.log is:
Checking .pth file support in
/Users/sophiaw/.hashdist/bld/cython/e2t4ieqlgjl3/lib/python2.7/site-packages/
/Users/sophiaw/.hashdist/bld/python/pf77qttkbtzn/bin/python -E -c pass
TEST FAILED:
/Users/sophiaw/.hashdist/bld/cython/e2t4ieqlgjl3/lib/python2.7/site-packages/
does NOT support .pth files error: bad install directory or
PYTHONPATH
You are attempting to install a package to a directory that is not on
PYTHONPATH and which Python does not read ".pth" files from. The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/Users/sophiaw/.hashdist/bld/cython/e2t4ieqlgjl3/lib/python2.7/site-packages/
and your PYTHONPATH environment variable currently contains:
'/Users/sophiaw/.hashdist/bld/cython/e2t4ieqlgjl3/Python.framework/Versions/2.7/lib/python2.7/site-packages:'
Here are some of your options for correcting the problem:
You can choose a different installation directory, i.e., one that is on PYTHONPATH or supports .pth files
You can add the installation directory to the PYTHONPATH environment variable. (It must then also be on PYTHONPATH whenever you run Python
and want to use the package(s) you are installing.)
You can set up the installation directory to support ".pth" files by using one of the approaches described here:
https://pythonhosted.org/setuptools/easy_install.html#custom-installation-locations
Please make the appropriate changes for your system and try again.
I've tried adding this to the bash_profile, but get the same error:
export PYTHONPATH=/Users/sophiaw/.hashdist/bld/cython/e2t4ieqlgjl3/lib/python2.7/site-packages:$PYTHONPATH.
How can I fix this error?
This was resolved by the fenics support group. to install FEniCS on OS X, Docker is a more convenient option.

Using cmake with enthought for python wrapping

I recently started trying to switch to canopy from ipython notebooks, which I switched to from MATLAB. I am working towards getting a matlab-like experience for development and research.
I am doing most of these setups cross-platform, but I am starting on OS X.
I have been attempting to install packages for use in canopy, some of which require compilation such as SimpleITK and VTK6.0. I had these both successfully installed in my regular python2.7 installation, but I'm having some trouble installing them for canopy. Right now, Im working on recompiling SimpleITK/Superbuild with CMAKE to recreate the python wrappers. It asks for your python executable, include dir, and python lib location. I found the python executeable from sys.executable from within canopy, and the include dir with 'mdfind -name Python.h, which turned out to be the default location, I used the default python lib.
These were
executeable: /Users/jmerkow/Library/Enthought/Canopy_64bit/User/bin/python
Include: /System/Library/Frameworks/Python.framework/Headers
Lib: /usr/lib/libpython2.7.dylib
But I get the following error upon make:
AssertionError: Filename /Applications/Canopy.app/appdata/canopy-1.1.0.1371.macosx-x86_64/Canopy.app/Contents/lib/python2.7/os.py does not start with any of these prefixes: ['/Users/jmerkow/Library/Enthought/Canopy_64bit/User', '/Library/Python/2.7/site-packages', '/Users/jmerkow/Library/Enthought/Canopy_64bit/User/Extras/lib/python', '/Users/jmerkow/Library/Python/2.7/site-packages', '/Users/jmerkow/.local/lib/python/2.7/site-packages', '/Users/jmerkow/Library/Python/2.7/lib/python/site-packages']
ERROR
-- Installing numpy from /Users/jmerkow/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy to /numpy
ERROR
/bin/sh: ../Testing/Installation/PythonVirtualenv/bin/python: No such file or directory
make[5]: *** [lib/_SimpleITK.so] Error 127
make[4]: *** [Wrapping/CMakeFiles/SimpleITK_PYTHON.dir/all] Error 2
make[3]: *** [all] Error 2
make[2]: *** [SimpleITK-prefix/src/SimpleITK-stamp/SimpleITK-build] Error 2
make[1]: *** [CMakeFiles/SimpleITK.dir/all] Error 2
make: *** [all] Error 2
Also, anyother tips to help me get this done are very welcome
EDIT BELOW
So I attempted to compile using:
/System/Library/Frameworks/Python.framework/Versions/Current/bin/python
/System/Library/Frameworks/Python.framework/Versions/Current/include/python2.7/
/System/Library/Frameworks/Python.framework/Versions/Current/lib/libpython2.7.dylib
This compiled and created and egg file named
SimpleITK-0.7.0.dev88_ge297c-py2.7-macosx-10.8-intel.egg
but I get the following error when I use enpkg
Traceback (most recent call last):
File "/Users/jmerkow/Library/Enthought/Canopy_64bit/User/bin/enpkg", line 10, in
sys.exit(main())
File "/Applications/Canopy.app/appdata/canopy-1.1.0.1371.macosx-x86_64/Canopy.app/Contents/lib/python2.7/site-packages/enstaller/main.py", line 702, in main
reqs.append(Req(name + ' ' + version))
File "/Applications/Canopy.app/appdata/canopy-1.1.0.1371.macosx-x86_64/Canopy.app/Contents/lib/python2.7/site-packages/enstaller/resolve.py", line 32, in init
raise Exception("Not a valid requirement: %r" % req_string)
Exception: Not a valid requirement: 'SimpleITK 0.7.0.dev88_ge297c-py2.7-macosx-10.8-intel.egg'
with easy_install I get this error:
Processing SimpleITK-0.7.0.dev88_ge297c-py2.7-macosx-10.8-intel.egg
removing '/Users/jmerkow/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/SimpleITK-0.7.0.dev88_ge297c-py2.7-macosx-10.8-intel.egg' (and everything under it)
creating /Users/jmerkow/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/SimpleITK-0.7.0.dev88_ge297c-py2.7-macosx-10.8-intel.egg
Extracting SimpleITK-0.7.0.dev88_ge297c-py2.7-macosx-10.8-intel.egg to /Users/jmerkow/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages
SimpleITK 0.7.0.dev88-ge297c is already the active version in easy-install.pth
Installed /Users/jmerkow/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/SimpleITK-0.7.0.dev88_ge297c-py2.7-macosx-10.8-intel.egg
Processing dependencies for SimpleITK==0.7.0.dev88-ge297c
Searching for SimpleITK==0.7.0.dev88-ge297c
Reading cant post
Reading cant post
Reading cant post
No local packages or download links found for SimpleITK==0.7.0.dev88-ge297c
error: Could not find suitable distribution for Requirement.parse('SimpleITK==0.7.0.dev88-ge297c')
It looked like I installed it, so I tried to import:
import SimpleITK
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6
You have configure SimpleITK to use your system python executable, library and include files. However, you are trying to run with the Canopy distribution. They are not binary compatible and the mismatch caused that type of program termination.
You canopy python executable was correctly found:
/Users/jmerkow/Library/Enthought/Canopy_64bit/User/bin/python
But you need to make the PYTHON_INCLUDE_DIR and PYTHON_LIBRARY consistent. Try the following commands to help you determine the correct path:
find /Users/jmerkow/Library/Enthought/Canopy_64bit/ -name Python.h
find /Users/jmerkow/Library/Enthought/Canopy_64bit/ -name lib python*.dylib

Installing PDQ on windows

I am trying to install "pretty damn quick", an analysis tool for Layered Queing networks.
However there seems to be a lot wrong with my system, and switching to Linux is not an option.
Here is what i tried to get the PDQ running:
First try: Python
I installed python2.7 and downloaded the PDQ for python distribution (its in the tarball in the python dir) :
C:\pdq\pdq42\python>python setup.py install
running install
running build
running build_ext
building 'pdq' extension
error: Unable to find vcvarsall.bat
This error stems from the fact that i supposedly dont have a C-compiler. Even though typing g++ gives me:
C:\pdq\pdq42\python>g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=c:/rtools/gcc-4.6.3/bin/../libexec/gcc/i686-w64-mingw3
3/lto-wrapper.exe
Target: i686-w64-mingw32
...snipped...
This problem is somehow documented? So i tried going over to Perl. It said there that the compiler comes with Strawberry Perl. So I installed that. Dmake gave me a lot of trouble but in the end I managed to install it.
C:\pdq\pdq42\perl5>perl Makefile.PL
Writing Makefile for pdq
C:\pdq\pdq42\perl5>dmake
Skip blib\lib\pdq.pm (unchanged)
...snipped...
g++.exe: error: MVA_Approx.o: No such file or directory
g++.exe: error: MVA_Canon.o: No such file or directory
g++.exe: error: MVA_Solve.o: No such file or directory
g++.exe: error: PDQ_Build.o: No such file or directory
g++.exe: error: PDQ_Exact.o: No such file or directory
g++.exe: error: PDQ_Globals.o: No such file or directory
g++.exe: error: PDQ_Report.o: No such file or directory
g++.exe: error: PDQ_Utils.o: No such file or directory
dmake: Error code 129, while making 'blib\arch\auto\pdq\pdq.dll'
Gives me new errors, that i cannot fix, since i cannot google them.
As the last resort i try out installing R, since this should work according to the documentation.
install.packages("c:\pdq\pdq_6.0-1.tar.gz",repos=NULL,type="source")
Warning: invalid package 'c:/pdq/pdq_6.0-1.tar.gz'
Error: ERROR: no packages specified
Warning messages:
1: running command '"C:/Programme/R/R-3.0.1/bin/i386/R" CMD INSTALL -l "C:\Programme\R\R-3.0.1\library" "c:/pdq/pdq_6.0-1.tar.gz"' had status 1
2: In install.packages("c:\pdq\pdq_6.0-1.tar.gz", repos = NULL, type = "source") :
installation of package ‘c:/pdq/pdq_6.0-1.tar.gz’ had non-zero exit status
However in this case i don't even know where to start debugging this to get it going.
So I am seeking help from SO. My question is:
Where did I go wrong and what can I do to find additional information leading to identify the problem? I would really like to have PDQ installed.

Categories

Resources