gpt4 book ai didi

Python 3 - 你如何告诉 pipenv 使用 python 3 而不是 python 2?

转载 作者:行者123 更新时间:2023-12-04 13:36:10 26 4
gpt4 key购买 nike

我正在尝试使用 requests 模块,这是我安装它的方式:

[ec2-user@ip-xxx-xx-xx-xxx newslookup]$ pipenv install requests
Creating a virtualenv for this project...
Pipfile: /var/www/html/newslookup/Pipfile
Using /usr/bin/python2 (2.7.14) to create virtualenv...
⠇ Creating virtual environment...Already using interpreter /usr/bin/python2
No LICENSE.txt / LICENSE found in source
New python executable in /home/ec2-user/.local/share/virtualenvs/newslookup-5acwuw4D/bin/python2
Also creating executable in /home/ec2-user/.local/share/virtualenvs/newslookup-5acwuw4D/bin/python
Installing setuptools, pip, wheel...
done.

✔ Successfully created virtual environment!
Virtualenv location: /home/ec2-user/.local/share/virtualenvs/newslookup-5acwuw4D
Creating a Pipfile for this project...
Installing requests...
Adding requests to Pipfile's [packages]...
✔ Installation Succeeded
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
✔ Success!
Updated Pipfile.lock (ab273c)!
Installing dependencies from Pipfile.lock (ab273c)...
🐍 ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 5/5 — 00:00:01
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.

这是我运行脚本时的样子:
[ec2-user@ip-xxx-xx-xx-xxx newslookup]$ python3 nasdaq_scrape_sec.py
Traceback (most recent call last):
File "nasdaq_scrape_sec.py", line 5, in <module>
import requests
ModuleNotFoundError: No module named 'requests'

如您所见,问题是当我安装它时,它使用的是 python 2 而不是 python 3 (Using /usr/bin/python2 (2.7.14))
如何告诉 pipenv 使用 Python 3 而不是 Python 2?

或者是否有安装请求的特定 python 3 方式?

最佳答案

在创建环境时,Pipenv 将自动扫描您的系统以查找与给定 VERSION 匹配的 Python。

pipenv --python VERSION

关于Python 3 - 你如何告诉 pipenv 使用 python 3 而不是 python 2?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56186765/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com