将文件夹作为包导入python

时间:2018-09-26 02:11:24

标签: python linux package

我正在使用Linux服务器,但没有权限使用pip安装软件包,因此我从https://github.com/blue-yonder/tsfresh下载了我需要的软件包:tsfresh,然后使用ftp将我下载的解压文件夹上传到Linux服务器,但是我如何import tsfresh

我将下载文件夹放在路径/upload/tsfresh中,而我的python工作目录位于/upload/中。

以下是我的文件夹upload的子文件夹

./tsfresh
./tsfresh/.github
./tsfresh/binder
./tsfresh/docs
./tsfresh/notebooks
./tsfresh/tests
./tsfresh/tsfresh
./tsfresh/docs/api
./tsfresh/docs/images
./tsfresh/docs/text
./tsfresh/docs/_static
./tsfresh/docs/_templates
./tsfresh/tests/integrations
./tsfresh/tests/units
./tsfresh/tests/integrations/examples
./tsfresh/tests/units/feature_extraction
./tsfresh/tests/units/feature_selection
./tsfresh/tests/units/scripts
./tsfresh/tests/units/transformers
./tsfresh/tests/units/utilities
./tsfresh/tsfresh/convenience
./tsfresh/tsfresh/examples
./tsfresh/tsfresh/feature_extraction
./tsfresh/tsfresh/feature_selection
./tsfresh/tsfresh/scripts
./tsfresh/tsfresh/transformers
./tsfresh/tsfresh/utilities

我的问题是:如何将tsfresh作为常规包导入。

1 个答案:

答案 0 :(得分:2)

它在您的项目文件夹中,对吗?然后

import tsfresh

如果它具有 init.py 使其成为模块,则可以使用。

如果它不在该文件夹中,请将其附加到sys.path

或者只是让您的管理员安装它。