我试图安装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) 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谢谢:)