python - 在python中将文件夹作为包导入
问题描述
我使用的是 linux 服务器,但我没有安装包的权限pip
,所以我下载了我需要的包:tsfresh
从https://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
作为普通包导入。
解决方案
它在您的项目文件夹中,对吗?然后
import tsfresh
如果它有一个init.py使其成为一个模块,它将起作用。
如果它不在该文件夹中,请将其附加到 sys.path
或者只是让您的管理员安装它。
推荐阅读
- unit-testing - 关于自动化测试用例的软件测试问题
- python-3.x - 如何解决 Dropout 的问题?
- git - git(lab) 是否可以在不修改克隆 URL 的情况下提供访问令牌?
- kotlin - 如何在 kotlin 中设置视图寻呼机可滑动和自动滑块?
- puppeteer - 如何使用 puppeteer.connect() 方法加载扩展
- python - 如何复制和更改数据?
- rest - 如何使用 CPPREST SDK 检索多个 Set-Cookie?
- windows - 如何让我的光标在 OhMyPosh 主题的高亮行之后的新行上?
- list - 如何根据自定义 Date Dart 对列表进行排序
- java - 使用 MapStruct 通过定位值进行枚举查找