小编roy*_*233的帖子

如何在 linux ubuntu 18.04 python 3.7 上使用 pip 安装 venv

我试图安装venv使用pip,它给了我下面的错误信息:

这是命令:

$ pip install venv

Run Code Online (Sandbox Code Playgroud)

和错误:

Collecting venv
Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 353, in run
    wb.build(autobuilding=True)
  File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 749, in build
    self.requirement_set.prepare_files(self.finder)
  File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 554, in _prepare_file
    require_hashes
  File "/usr/lib/python2.7/dist-packages/pip/req/req_install.py", line 278, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "/usr/lib/python2.7/dist-packages/pip/index.py", line 465, in find_requirement
    all_candidates = self.find_all_candidates(req.name)
  File "/usr/lib/python2.7/dist-packages/pip/index.py", line 423, …
Run Code Online (Sandbox Code Playgroud)

python pip virtualenv

6
推荐指数
1
解决办法
1821
查看次数

如何在python中使用多重处理?

import time
from multiprocessing import Process
start = time.perf_counter()


def sleep():
    print('Sleeping 1 second(s)...')
    time.sleep(1)
    return 'Done Sleeping...'

p1 = Process(target = sleep)
p2 = Process(target = sleep)
p1.start()
p2.start()
p1.join()
p2.join()
finish = time.perf_counter()
print(f'Finished in {round(finish-start, 2)} second(s)')
Run Code Online (Sandbox Code Playgroud)

输出:

Finished in 0.17 second(s)
Run Code Online (Sandbox Code Playgroud)

我尝试使用多重处理,但是当我运行代码时,它在0.17秒钟内结束,而不是它原本应该的1倍,这根本不会影响该功能。

如果我将这样的括号放进去:

p1 = Process(target = sleep())
p2 = Process(target = sleep())
Run Code Online (Sandbox Code Playgroud)

输出:

Sleeping 1 second(s)...
Sleeping 1 second(s)...
Finished in 2.35 second(s)
Run Code Online (Sandbox Code Playgroud)

Windows 10. python 3.7.4谢谢:)

python multiprocessing python-3.x python-multiprocessing

4
推荐指数
1
解决办法
113
查看次数