FiPy“基本目录”在哪里?

2024-10-16 20:48:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我最近通过MacPorts在我的Macbook上安装了FiPy包,以及所有的依赖项。我在Python中将FiPy和NumPy称为包没有问题。在

现在我已经开始工作了,我想看看这些例子。但是,我在我的计算机中找不到“基本目录”或FiPy目录。在

如何找到基本目录? 如果我通过Macports安装了所有这些,我甚至有基本目录吗?在

作为注释,我用的是Python27。在

求求你,救命!谢谢。在


Tags: numpy目录计算机中将例子macbookpython27macports
3条回答

尝试:

import FiPy
print FiPy.__file__

从FiPy docs(http://www.ctcms.nist.gov/fipy/README.html)中:

When references are made to file system paths, it is assumed that the current working directory is the FiPy distribution directory, refered to as the “base directory”, such that:

examples/diffusion/steadyState/mesh1D.py

will correspond to, e.g.:

/some/where/FiPy-X.Y/examples/diffusion/steadyState/mesh1D.py

这意味着如果FiPy存储库被克隆或tarball解包,然后目录被改为fipy/,那么就是工作目录。它将有setup.py和{}。如果在不克隆或不使用tarball(例如使用pip代替)的情况下安装FiPy,则分发目录(基本目录)将不可用。在

它不是从import fipy; print(fipy.__file__)返回的路径。这就是安装路径。在

因为我对Ubuntu也有同样的问题,所以我把这个贴在这里。 如果您使用miniconda或anaconda安装,它将是:

/home/username/miniconda<version>/envs/<name of the environemnt you installed fipy in> 如果出现“找不到fipy module”的错误,则不需要导出路径,只需: conda activate <nameOfEnvironment you installed fipy there>

相关问题 更多 >