简体   繁体   English

Python3 找不到 pip3 安装的模块,即使它安装了 defintley

[英]Python3 cannot find module installed by pip3 even though it is deffintley installed

I have a folder structure我有一个文件夹结构

root
|-setup.py
|-src
| |-BDDexample
|   |-ExampleSystem.py (contains a class called ExampleSystem)
|   |-__init__.py (empty file)
|
|-tests
  |-cucumber
    |-features
      |-steps
        |-EnableSystemStepImpl.py

My setup.py file is:我的setup.py文件是:

#!/usr/local/bin/python3.6
from setuptools import setup, find_packages

setup(
    name="BDDexample",
    version="0.2",
    packages=find_packages()
)

I then installed this using pip3 install .然后我使用pip3 install . . . I also tried python3 setup.py bdist_wheel followed by pip3 install dist/BDDexample-0.2-py3-none-any.whl .我也试过python3 setup.py bdist_wheel然后是pip3 install dist/BDDexample-0.2-py3-none-any.whl

It finds the module BDDexample, and I can test this by typing pip3 list , which shows the module.它找到模块 BDDexample,我可以通过键入pip3 list来测试它,它显示了模块。

However, in EnableSystemStepImpl.py I have the line:但是,在EnableSystemStepImpl.py有一行:

from BDDexample.ExampleSystem import ExampleSystem

And I get the error:我得到错误:

ModuleNotFoundError: No module named 'BDDexample'

When I try to run this file.当我尝试运行此文件时。

Why is this happening!为什么会这样! It is installed, so why can it not find it.已经安装了,为什么找不到。 I know there are loads of python import questions but it seems like I am doing everything right.我知道有很多 python 导入问题,但似乎我做的一切都是正确的。

The file BDDexample.ExampleSystem is not getting extracted from ExampleSystem because it might not be in a direct accessible path for the pc to extract.文件 BDDexample.ExampleSystem 没有从 ExampleSystem 中提取,因为它可能不在 PC 提取的直接可访问路径中。 Please check if it is in your c drive etc...请检查它是否在您的c盘等中...

I've found the answer, it's because I shouldn't have had the src folder.我找到了答案,因为我不应该有src文件夹。 I've changed my directory structure to:我已将目录结构更改为:

root
|-setup.py
|-BDDexample
| |-ExampleSystem.py (contains a class called ExampleSystem)
| |-__init__.py (empty file)
|
|-tests
  |-cucumber
    |-features
      |-steps
        |-EnableSystemStepImpl.py

And it now works.现在它可以工作了。

I assume find_packages couldn't find the BDDexample module because it was inside another folder.我假设find_packages找不到BDDexample模块,因为它在另一个文件夹中。

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

相关问题 即使正确安装,Python3仍找不到模块 - Python3 won't find a module even though it is properly installed Python3 找不到 pip3 安装的模块 - Python3 does not find modules installed by pip3 scikit-surprise:python 找不到模块,即使 pip 将其列为已安装 - scikit-surprise: python cannot find module even though pip lists it as installed 为什么R库'ssw'找不到通过pip3安装的python模块,尽管pip3模块安装满意? - Why R library 'ssw' cannot find python module installed via pip3, although pip3 module installation is satisfied? Django找不到pip3已安装的模块 - Django cant find pip3 installed module mac 上安装了 python3 和 pip 但找不到 pip3 命令 - python3 and pip is installed on mac but pip3 command not found PyCharm 没有名为“nltk”的模块,即使我使用 pip3 安装了它? - PyCharm No module named 'nltk' even though I've installed it using pip3? ModuleNotFoundError: No module named 'psycopg2' (python3, mac, pip3 显示 psycopg2 已成功安装) - ModuleNotFoundError: No module named 'psycopg2' (python3, mac, pip3 shows psycopg2 successfully installed) 为什么pip3安装的模块不能用python3? - Why modules installed by pip3 can not be used python3? 如何找到pip3已安装模块的导入名称/密钥 - How to find import name/key of pip3 installed module
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM