我使用以下方法创建了一个虚拟环境:
mkvirtualenv env_name --python=python3.9
Run Code Online (Sandbox Code Playgroud)
然后我尝试从 Pipfile 安装:
pipenv install --dev
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
pipenv.patched.notpip._internal.exceptions.UnsupportedPythonVersion: pylint requires Python '~=3.6' but the running Python is 2.7.17
Run Code Online (Sandbox Code Playgroud)
我检查了我的Python版本,它是正确的:
$ python --version
Python 3.9.1
Run Code Online (Sandbox Code Playgroud)
为什么它告诉我我的 python 版本是 2.7.17?当我使用以下命令安装时,不会发生这种情况:
pip install pylint==2.7.2
Run Code Online (Sandbox Code Playgroud) 我想在 VsCode 中使用 pip 安装 fastapi
pip install fastapi[all]
Run Code Online (Sandbox Code Playgroud)
但我遇到了这个巨大的错误。我究竟做错了什么?
ERROR: Command errored out with exit status 1:
command: 'C:\Users\krish\Desktop\Codes\API\venv\Scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\krish\\AppData\\Local\\Temp\\pip-install-eqmneh6a\\httptools_b8491d7c29264d1c9eb72c9367d56d7a\\setup.py'"'"'; __file__='"'"'C:\\Users\\krish\\AppData\\Local\\Temp\\pip-install-eqmneh6a\\httptools_b8491d7c29264d1c9eb72c9367d56d7a\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\krish\AppData\Local\Temp\pip-record-wvba_iw2\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\krish\Desktop\Codes\API\venv\include\site\python3.10\httptools'
cwd: C:\Users\krish\AppData\Local\Temp\pip-install-eqmneh6a\httptools_b8491d7c29264d1c9eb72c9367d56d7a\
Complete output (25 lines):
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.10
creating build\lib.win-amd64-3.10\httptools
copying httptools\_version.py -> build\lib.win-amd64-3.10\httptools
copying httptools\__init__.py …Run Code Online (Sandbox Code Playgroud) 如果我有一个清单
\nx=[0.0,0.0,2.0,3.0,0.0,2.0]\nRun Code Online (Sandbox Code Playgroud)\n我基本上想计算列表中的项目数量,但只在前导零之后开始,我该怎么做?请记住,我想计算列表中间的零,而不是开头的零。
\n我\xe2\x80\x99已经尝试过这个:
\nn=0\nfor i in x:\n while i==0.0:\n break\n if i!=0.0:\n n=n+1\nRun Code Online (Sandbox Code Playgroud)\n但它没有\xe2\x80\x99t 得到4,这是我想要的输出,因为我只想包含2.0,3.0,0.0,2.0。
\n我希望我的代码是这样的,并在代码中使用用户名和密码参数作为字符串。
def check_registration_rules(username='password'):
Run Code Online (Sandbox Code Playgroud)
像这样调用函数:
check_registration_rules(parsap1378='pass')
Run Code Online (Sandbox Code Playgroud) 这是我当前的代码:
parser = argparse.ArgumentParser(description='Optic disc segmentation.')
parser.add_argument('-f', dest='file', action='store', type=str, help='The image to process.')
args = parser.parse_args()
print(args.accumulate(args.integers))
Run Code Online (Sandbox Code Playgroud)
我在最后一行不断收到此错误:
AttributeError: 'Namespace' object has no attribute 'accumulate'
Run Code Online (Sandbox Code Playgroud) 这是错误,我不知道错误在哪里:
> & C:/Users/tanel/AppData/Local/Programs/Python/Python38/python.exe
"c:/Users/tanel/Documents/Projects/Coding/Python/Game Alien/game.py"
File "<stdin>", line 1
& C:/Users/tanel/AppData/Local/Programs/Python/Python38/python.exe "c:/Users/tanel/Documents/Projects/Coding/Python/Game Alien/game.py"
^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)