首页 > 解决方案 > 在python中将文件夹作为包导入

问题描述

我使用的是 linux 服务器,但我没有安装包的权限pip,所以我下载了我需要的包:tsfreshhttps://github.com/blue-yonder/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作为普通包导入。

标签: pythonlinuxpackage

解决方案


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

import tsfresh

如果它有一个init.py使其成为一个模块,它将起作用。

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

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


推荐阅读