我的系统时 MacOS,以 xlwt 为例,具体操作如下。

1. 执行 pip3 install xlwt (我需要安装包到 Python 3 的环境中,所以用 pip3),如果这个包已经成功安装,则会出现包所在的路径。

Python: 通过 pip 安装第三方包后依然不能 import

 

 

2. 打开 ~/.bash_profile(可用 sudo vi ~/.bash_profile 打开文件编辑),添加以下内容,引号内为上一步显示的路径。

PYTHONPATH="/usr/local/lib/python3.7/site-packages"
export PYTHONPATH

3. 执行 source ~/.bash_profile 。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-04-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-06
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-09
  • 2021-12-27
相关资源
相似解决方案