iT邦幫忙

0

新手求救 執行pipenv update出錯,系統會應內容如下;請問原因與如何處理

  • 分享至 

  • xImage

Microsoft Windows [版本 10.0.18363.1256]
(c) 2019 Microsoft Corporation. 著作權所有,並保留一切權利。
(Line_K) C:\Users\William\PycharmProjects\Line_K>pipenv update
Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV
_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
Running $ pipenv lock then $ pipenv sync.
Traceback (most recent call last):
File "c:\users\william\appdata\local\programs\python\python37\lib\site-packages\pipenv\project.py", line 567, in _parse_pipfile
return tomlkit.parse(contents)
File "c:\users\william\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\tomlkit\api.py", line 49, in parse
return Parser(string).parse()
File "c:\users\william\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\tomlkit\parser.py", line 146, in parse
key, value = self._parse_table()
File "c:\users\william\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\tomlkit\parser.py", line 1056, in _parse_table
table.raw_append(_key, item)
File "c:\users\william\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\tomlkit\items.py", line 937, in raw_append
self._value.append(key, _item)
File "c:\users\william\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\tomlkit\container.py", line 144, in append
raise KeyAlreadyPresent(key)
tomlkit.exceptions.KeyAlreadyPresent: Key "'matplotlib'" already exists.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\users\william\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\toml\decoder.py", line 511, in loads
multibackslash)
File "c:\users\william\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\toml\decoder.py", line 780, in load_line
raise ValueError("Duplicate keys!")
ValueError: Duplicate keys!

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\users\william\appdata\local\programs\python\python37\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "c:\users\william\appdata\local\programs\python\python37\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\Users\William\AppData\Local\Programs\Python\Python37\Scripts\pipenv.exe_main
.py", line 7, in
File "c:\users\william\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\click\core.py", line 829, in call
return self.main(*args, **kwargs)
File "c:\users\william\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\click\core.py", line 782, in main
rv = self.invoke(ctx)
File "c:\users\william\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\click\core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\users\william\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\click\core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\william\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "c:\users\william\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\click\decorators.py", line 73, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "c:\users\william\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "c:\users\william\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\click\decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "c:\users\william\appdata\local\programs\python\python37\lib\site-packages\pipenv\cli\command.py", line 591, in update
write=not state.quiet,
File "c:\users\william\appdata\local\programs\python\python37\lib\site-packages\pipenv\core.py", line 1064, in do_lock
pre = project.settings.get("allow_prereleases")
File "c:\users\william\appdata\local\programs\python\python37\lib\site-packages\pipenv\project.py", line 601, in settings
return self.parsed_pipfile.get("pipenv", {})
File "c:\users\william\appdata\local\programs\python\python37\lib\site-packages\pipenv\project.py", line 544, in parsed_pipfile
parsed = self._parse_pipfile(contents)
File "c:\users\william\appdata\local\programs\python\python37\lib\site-packages\pipenv\project.py", line 571, in _parse_pipfile
return toml.loads(contents)
File "c:\users\william\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\toml\decoder.py", line 513, in loads
raise TomlDecodeError(str(err), original, pos)
toml.decoder.TomlDecodeError: Duplicate keys! (line 14 column 1 char 165)

(Line_K) C:\Users\William\PycharmProjects\Line_K>

看更多先前的討論...收起先前的討論...
ccutmis iT邦高手 2 級 ‧ 2020-12-19 13:18:13 檢舉
https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way#%E7%B2%BE%E7%A2%BA%E7%9A%84%E6%8F%8F%E8%BF%B0%E5%95%8F%E9%A1%8C%E4%B8%A6%E8%A8%80%E4%B9%8B%E6%9C%89%E7%89%A9

好的提問通常伴隨著好的解答。這個是新手最需要學習的地方,
還有可以善用Google搜尋,舉個例把你的問題搜一下 "pipenv update error pipenv found itself running within a virtual environment" 就能找到很多遇過類似問題的人了,仔細爬一爬大概答案就有了。

我沒用pipenv 不管是pip 或是virtualenv我都是純手動派,所以只能亂猜你這問題可能跟pipenv的版本有關(例如pyinstaller如果在python3.8上面跑可能打包exe會有某些bug,但是在Pythom3.7上面跑就正常),如果你是看書學的,最好是安裝跟書本一樣的版本練習,以免在新手期還沒學Hello World先學偵錯
我現在也將要成為手動派了,網頁找的都試過了,外國、中國、台灣的都試過了,都會出現新的錯誤,無解.............
marlin12 iT邦研究生 5 級 ‧ 2020-12-20 12:19:46 檢舉
原因是Pipfile裏面有多過一個key的名稱是matplotlib,tomlkit無法處理。嘗試把它們改為不同的名稱吧 (例如:matplotlib, matplotlib_mac, matplotlib_linux, ...)。這是不會影響組件安裝後的名稱(即是,import仍然是matplotlib)。
python這東西......畢竟有太多第三方class,很難避免到處都是坑的事件發生,網上的討論也都是個人心得,第三方設計人很少自己出面解釋問題及處理方法,SO........

自己掉坑,那就想辦法網上找方法,一個個試,試到爬出來為止吧
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答