简体   繁体   English

pip3 install [module] 创建新的“/.local/.../site-packages”目录?

[英]pip3 install [module] creating new "/.local/.../site-packages" directory?

relatively new to the raspberry pi and python world.相对较新的树莓派和 python 世界。 Right now I'm attempting to install:现在我正在尝试安装:

pip3 install keyboard

Problem is, it is creating & saving into this folder structure...问题是,它正在创建并保存到这个文件夹结构中......

/home/pi/.local/lib/python3.7/site-packages/keyboard/

It's creating a '.local'?它正在创建一个“.local”? Which I have never seen before.这是我以前从未见过的。 Whenever I launch python3 in the terminal and 'import keyboard'.每当我在终端中启动 python3 并“导入键盘”时。 The module is not found.未找到该模块。 I've learned the sys.path is only using these directories我了解到 sys.path 只使用这些目录

['', '/usr/lib/python37.zip', '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', 

'/usr/local/lib/python3.7/dist-packages', '/usr/lib/python3/dist-packages']

This is the first time I've ran into this error.这是我第一次遇到这个错误。 I did setup SublimeText3 & a SFTP Package which syncs Remote >> Local files.我确实设置了 SublimeText3 和一个同步远程 >> 本地文件的 SFTP 包。 I don't see why that would interfere with module installs?我不明白为什么这会干扰模块安装?

Suggestions I've read to fix the 'module not found' error is to edit the SYSPATH.我读过的修复“找不到模块”错误的建议是编辑 SYSPATH。 Instead, I'd like to know WHY it's creating this new weird directory.相反,我想知道它为什么要创建这个新的奇怪目录。 And what can I do to make it save to one of the supported sys.path directories?我该怎么做才能将其保存到受支持的 sys.path 目录之一?


Debian Bug Report about why site-packages is not used in sys.path关于为什么在 sys.path 中不使用 site-packages 的Debian 错误报告

Looks like its a matter of putting sudo before pip3 install [module].... >.<看起来是在 pip3 install [module].. >.<

在此处输入图片说明

I am not sure about the problem, but something to fix it.我不确定这个问题,但有办法解决它。

Solution: Install the package in your current directory.解决方案:将软件包安装在您当前的目录中。

$ pip3 install -t . keyboard

You can see the solution here您可以在此处查看解决方案图片

NB:注意:

  • When ever you need the package you need to install it in your project directory.当你需要这个包时,你需要将它安装在你的项目目录中。
  • Try installing the package in '/usr/lib/python3.7' path to make is accessible always.尝试将软件包安装在“/usr/lib/python3.7”路径中,以使始终可以访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM