天天看点

【python】本地导入包的方式

首先,需要搞清楚自己用的是什么版本的python。如果是在同一个电脑上安装了多个环境的,先进入anaconda找到对应环境,然后进入这个环境的python或者先进操作框再进python。

#64位:
import pip._internal
print(pip._internal.pep425tags.get_supported())

#32位:
import pip; 
print(pip.pep425tags.get_supported())

#如果以上两个都不行,备选方案:
import pip._internal.pep425tags
print(pip._internal.pep425tags.get_supported())
           

输入以上代码后就能获得当前的对应版本号,如:

[(‘cp36’, ‘cp36m’, ‘win_amd64’), (‘cp36’, ‘none’, ‘win_amd64’), (‘py3’, ‘none’, ‘win_amd64’), (‘cp36’, ‘none’, ‘any’), (‘cp3’, ‘none’, ‘any’), (‘py36’, ‘none’, ‘any’), (‘py3’, ‘none’, ‘any’), (‘py35’, ‘none’, ‘any’), (‘py34’, ‘none’, ‘any’), (‘py33’, ‘none’, ‘any’), (‘py32’, ‘none’, ‘any’), (‘py31’, ‘none’, ‘any’), (‘py30’, ‘none’, ‘any’)]

注意看第一个:(‘cp36’, ‘cp36m’, ‘win_amd64’),这就是要下载的whl的版本号。

进入 Python Extension Packages 下载对应包的对应版本whl文件。

下载好之后,再进入命令行,通过命令将whl导入

pip  install <文件路径>
           

之后等待安装就可以了。

目前pycharm不能直接导入skimage(scikit-image),通过这种方式可以安装后使用。