malcolmw / pykonal

Travel-time calculator based on the fast-marching method solution to the Eikonal equation.
https://malcolmw.github.io/pykonal-docs/
GNU General Public License v3.0
154 stars 55 forks source link

Issue with initial import #21

Closed JBAjo-Franklin closed 2 years ago

JBAjo-Franklin commented 2 years ago

Not a python expert - installing via the conda path and everything seemed to go fine however I'm not able to load pykonal within python (missing module error) when running the examples,

import pykonal Traceback (most recent call last): File "", line 1, in File "/Users/admin/Rice Geophysics Dropbox/Jonathan Ajo-Franklin/riceSeisMat/externalCodes/pykonal-0.2.3b3/pykonal/init.py", line 10, in from .solver import EikonalSolver ModuleNotFoundError: No module named 'pykonal.solver'

For reference on environment .... Patch 3 version of pykonal-0.2.3b3 Python 3.8.12 | packaged by conda-forge | (default, Oct 12 2021, 21:50:56) [Clang 11.1.0 ] on darwin

malcolmw commented 2 years ago

Hi, @JBAjo-Franklin, Thanks for reporting this.

What directory are you in when you start your Python interpreter? Make sure you leave the PyKonal source code directory before opening the interpreter.

JBAjo-Franklin commented 2 years ago

Interesting - I was in the pykonal directory. Unfortunately, different error when I'm in home or somewhere else

(base) admin@Jonathans-MacBook-Pro riceSeisMat % python Python 3.8.3 (default, Jul 2 2020, 11:26:31) [Clang 10.0.0 ] :: Anaconda, Inc. on darwin Type "help", "copyright", "credits" or "license" for more information.

import numpy as np import pykonal Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'pykonal'

I assume this is a path issue for module; I'm not familiar with the way conda and pip set this up for python - something new to learn - J.

malcolmw commented 2 years ago

From the top-level directory of the source code, executing pip install . will install the package into whichever conda environment is currently active. For example, you might try something like

>$ conda create --name py39 python=3.9 cython
>$ conda activate py39
(py39) >$ cd src/pykonal
(py39) >$ pip install .
(py39) >$ cd ~
(py39) >$ python
>>> import pykonal
JBAjo-Franklin commented 2 years ago

Thanks! Turns out a remove/reinstall solved the mysterious path problem. Appreciate the help/response - now to solve some more interesting problems ;)

Best - J.

malcolmw commented 2 years ago

Great! Closing this Issue. Have fun!