简体   繁体   English

导入pyinputplus模块的问题

[英]problem with importing pyinputplus module

I have a problem with importing module pyinputplus to my project.我在将模块 pyinputplus 导入我的项目时遇到问题。 I type 'pip install pyinputplus' in cmd (iam using windows), all was fine, cmd showed that installation was succes.我在cmd中输入'pip install pyinputplus'(我使用windows),一切都很好,cmd显示安装成功。 But when i try: import pyinputplus in my project in PyCharm i have an error: ModuleNotFoundError: No module named 'pyinputplus'但是当我尝试:在 PyCharm 的项目中导入 pyinputplus 时,出现错误:ModuleNotFoundError: No module named 'pyinputplus'

Some weeks ago i installed packed named selenium, and everything was fine.几周前,我安装了名为 selenium 的打包软件,一切都很好。 All works with no problem.一切正常。 I do the same with pyinputplus and its wrong...我对 pyinputplus 做同样的事情,但它是错误的...

Moreover, i tried to use pyinputplus in cmd and all was also fine.此外,我尝试在 cmd 中使用 pyinputplus 并且一切都很好。 Where is a problem?哪里有问题?

Pycharm creates virtual environments for each project, so installing it system-wide (as you just did) doesn't make it available to your pycharm project. Pycharm 为每个项目创建虚拟环境,因此在系统范围内安装它(就像您刚刚所做的那样)不会使其可用于您的 pycharm 项目。

Easier Solution更简单的解决方案

The easy solution is to go to preferences, click "python interpreter" (you may need to expand "project"), then click the plus icon at the bottom of the package list, and search for pyinputplus and click install.简单的解决方法是进入首选项,单击“python解释器”(您可能需要展开“项目”),然后单击包列表底部的加号图标,搜索pyinputplus并单击安装。 It is now installed, but won't work for any other project.它现在已安装,但不适用于任何其他项目。

Long-term Solution长期解决方案

Keeping packages seperate has it's advantages, like allowing you to have many different versions of packages, and avoid conflicts, but you may prefer for everything to use the same interpreter.将包分开有其优势,例如允许您拥有许多不同版本的包,并避免冲突,但您可能更喜欢所有内容都使用相同的解释器。 If so, go to the same "python interpreter" page in preferences, and change the interpreter in the dropdown to the other available one.如果是这样,请转到首选项中相同的“python 解释器”页面,并将下拉列表中的解释器更改为另一个可用的解释器。 If there are more than 2, you may need to use trial and error.如果超过 2 个,您可能需要使用试错法。

Have a look at the documentation here: https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html#interpreter-settings看看这里的文档: https : //www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html#interpreter-settings

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

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