基准测试安装错误,ModuleNotFoundError:没有名为“main”的模块

2024-10-06 11:29:46 发布

您现在位置:Python中文网/ 问答频道 /正文

为什么会出现这种错误?我无法再安装基准测试了。我需要导入“get_data”,它包含在基准测试中。怎么了

pip安装基准

Collecting benchmark
  Using cached benchmark-0.1.5.tar.gz (7.1 kB)
    ERROR: Command errored out with exit status 1:
     command: /opt/anaconda3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/cf/gs10w86j2n1bf2_x86gmqscw0000gn/T/pip-install-qq5kp9hk/benchmark/setup.py'"'"'; __file__='"'"'/private/var/folders/cf/gs10w86j2n1bf2_x86gmqscw0000gn/T/pip-install-qq5kp9hk/benchmark/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/cf/gs10w86j2n1bf2_x86gmqscw0000gn/T/pip-pip-egg-info-_7t1tj64
         cwd: /private/var/folders/cf/gs10w86j2n1bf2_x86gmqscw0000gn/T/pip-install-qq5kp9hk/benchmark/
    Complete output (7 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/cf/gs10w86j2n1bf2_x86gmqscw0000gn/T/pip-install-qq5kp9hk/benchmark/setup.py", line 3, in <module>
        from benchmark import __VERSION__
      File "/private/var/folders/cf/gs10w86j2n1bf2_x86gmqscw0000gn/T/pip-install-qq5kp9hk/benchmark/benchmark/__init__.py", line 10, in <module>
        from main import BenchmarkProgram, main
    ModuleNotFoundError: No module named 'main'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Tags: installpippyeggvarsetup基准private
1条回答
网友
1楼 · 发布于 2024-10-06 11:29:46

benchmark与python版本不兼容>;=3.

您需要python 2


在使用python 3的虚拟环境中

~/workspace/so via 🐍 v3.8.5 via C python3 
❯ pip install benchmark
Collecting benchmark
  Downloading benchmark-0.1.5.tar.gz (7.1 kB)
    ERROR: Command errored out with exit status 1:
     command: /home/louis/miniconda3/envs/python3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-wyj1c1sn/benchmark/setup.py'"'"'; __file__='"'"'/tmp/pip-install-wyj1c1sn/benchmark/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info  egg-base /tmp/pip-pip-egg-info-0qo4nmp7
         cwd: /tmp/pip-install-wyj1c1sn/benchmark/
    Complete output (7 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-wyj1c1sn/benchmark/setup.py", line 3, in <module>
        from benchmark import __VERSION__
      File "/tmp/pip-install-wyj1c1sn/benchmark/benchmark/__init__.py", line 10, in <module>
        from main import BenchmarkProgram, main
    ModuleNotFoundError: No module named 'main'
                        
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

对于python 2:

~/workspace/so via 🐍 v2.7.18 :: Anaconda, Inc. via C python2 
❯ pip install benchmark           
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting benchmark
  Using cached https://files.pythonhosted.org/packages/e9/af/e0390a38d8d8920a189775102d69fa19107c0b67f75c7934bc166e05d504/benchmark-0.1.5.tar.gz
Building wheels for collected packages: benchmark
  Building wheel for benchmark (setup.py) ... done
  Created wheel for benchmark: filename=benchmark-0.1.5-cp27-none-any.whl size=6336 sha256=e4878032c29d27e51067deb70363bf7b7108fa93f9458befabfbbcce3b3d4598
  Stored in directory: /home/louis/snap/codium/common/.cache/pip/wheels/a4/3f/24/d0ed8ae3351441f06a4a17a6ea3f5c500527144a9aebfbb05c
Successfully built benchmark
Installing collected packages: benchmark
Successfully installed benchmark-0.1.5

相关问题 更多 >