如何安装src-0.0.7软件包?

时间:2020-06-29 14:42:17

标签: python pip

我正在构建用于运行代码,不在colab中的代码“ import src”或我的PC的环境。我看到了PyPl页面,上面写着我应该运行'pip install src',但是我仍然做不到。

(base) oblic@oblic-PC:~$ pip install src
Collecting src
  Using cached src-0.0.7.zip (6.3 kB)
Building wheels for collected packages: src
  Building wheel for src (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/oblic/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-qffzaygw/src/setup.py'"'"'; __file__='"'"'/tmp/pip-install-qffzaygw/src/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-m62_ocqn
       cwd: /tmp/pip-install-qffzaygw/src/
  Complete output (41 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib
  creating build/lib/src
  copying src/__init__.py -> build/lib/src
  running egg_info
  writing src.egg-info/PKG-INFO
  writing dependency_links to src.egg-info/dependency_links.txt
  writing entry points to src.egg-info/entry_points.txt
  writing requirements to src.egg-info/requires.txt
  writing top-level names to src.egg-info/top_level.txt
  reading manifest file 'src.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  writing manifest file 'src.egg-info/SOURCES.txt'
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-qffzaygw/src/setup.py", line 96, in <module>
      'install_lib': InstallCommand,
    File "/home/oblic/anaconda3/lib/python3.7/site-packages/setuptools/__init__.py", line 144, in setup
      return distutils.core.setup(**attrs)
    File "/home/oblic/anaconda3/lib/python3.7/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/home/oblic/anaconda3/lib/python3.7/distutils/dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "/home/oblic/anaconda3/lib/python3.7/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/home/oblic/anaconda3/lib/python3.7/site-packages/wheel/bdist_wheel.py", line 226, in run
      reinit_subcommands=True)
    File "/home/oblic/anaconda3/lib/python3.7/site-packages/setuptools/__init__.py", line 198, in reinitialize_command
      cmd = _Command.reinitialize_command(self, command, reinit_subcommands)
    File "/home/oblic/anaconda3/lib/python3.7/distutils/cmd.py", line 306, in reinitialize_command
      reinit_subcommands)
    File "/home/oblic/anaconda3/lib/python3.7/distutils/dist.py", line 950, in reinitialize_command
      for sub in command.get_sub_commands():
    File "/home/oblic/anaconda3/lib/python3.7/distutils/cmd.py", line 324, in get_sub_commands
      if method is None or method(self):
    File "/home/oblic/anaconda3/lib/python3.7/distutils/command/install.py", line 631, in has_lib
      return (self.distribution.has_pure_modules() or
  AttributeError: 'NoneType' object has no attribute 'has_pure_modules'
  ----------------------------------------
  ERROR: Failed building wheel for src
  Running setup.py clean for src
Failed to build src
Installing collected packages: src
    Running setup.py install for src ... error
    ERROR: Command errored out with exit status 1:
     command: /home/oblic/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-qffzaygw/src/setup.py'"'"'; __file__='"'"'/tmp/pip-install-qffzaygw/src/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-4y4re6aq/install-record.txt --single-version-externally-managed --compile --install-headers /home/oblic/anaconda3/include/python3.7m/src
         cwd: /tmp/pip-install-qffzaygw/src/
    Complete output (2 lines):
    running install
    You've probably made a mistake here and are trying to install from a 'src' directory which doesn't exist.
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/oblic/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-qffzaygw/src/setup.py'"'"'; __file__='"'"'/tmp/pip-install-qffzaygw/src/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-4y4re6aq/install-record.txt --single-version-externally-managed --compile --install-headers /home/oblic/anaconda3/include/python3.7m/src Check the logs for full command output.

以上是我尝试设置软件包“ src”时的输出。 我不知道是否可以发布此消息。

1 个答案:

答案 0 :(得分:1)

谢谢大家。您确实帮助我弄清楚了问题所在。现在让我澄清一下,希望这种情况可以对其他人有所帮助。

我想实际运行的代码包含在名为“ src”的字典中。 然后程序员用下面的代码行编写代码,例如main.py: ''' 将src.utils导入为utils ''' 我在运行〜/ main / src词典中的代码时犯了一个错误,因此python返回了一个错误“ no src module”。然后我很愚蠢地找到src包。

实际上,一种运行代码的简单方法是将所有.py文件复制到上层字典(在我的情况下为〜/ main /),然后在〜/ main /中运行main.py,因为〜/ main / src /包含utils.py,则代码将顺利运行,并且完全没有模块丢失。