使用 python venv 时出现 ValueError
ValueError when using python venv
我目前正在尝试使用 python 中的 API 密钥连接到我的保管箱帐户。当我 运行 它不使用虚拟环境时,我可以从下面的代码中获取我的个人资料信息。
import dropbox
d = dropbox.Dropbox("myAPIkey")
print(d.users_get_current_account())
但是当我 运行 使用我的 python venv 的代码时,我得到这个错误
Traceback (most recent call last):
File "c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\urllib3\util\timeout.py", line 142, in _validate_timeout
float(value)
TypeError: float() argument must be a string or a number, not 'Timeout'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "d:/Desktop/FYP/FYP-TheBoyes/dropbox_tester.py", line 8, in <module>
print(d.users_get_current_account())
File "c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\dropbox\base.py", line 5216, in users_get_current_account
r = self.request(
File "c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\dropbox\dropbox_client.py", line 321, in request
res = self.request_json_string_with_retry(host,
File "c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\dropbox\dropbox_client.py", line 476, in request_json_string_with_retry
return self.request_json_string(host,
File "c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\dropbox\dropbox_client.py", line 588, in request_json_string
r = self._session.post(url,
File "d:\Desktop\FYP\FYP-Django\venv\lib\site-packages\requests\sessions.py", line 522, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "d:\Desktop\FYP\FYP-Django\venv\lib\site-packages\requests\sessions.py", line 475, in request
resp = self.send(prep, **send_kwargs)
File "d:\Desktop\FYP\FYP-Django\venv\lib\site-packages\requests\sessions.py", line 596, in send
r = adapter.send(request, **kwargs)
File "d:\Desktop\FYP\FYP-Django\venv\lib\site-packages\requests\adapters.py", line 413, in send
resp = conn.urlopen(
File "c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\urllib3\connectionpool.py", line 687, in urlopen
timeout_obj = self._get_timeout(timeout)
File "c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\urllib3\connectionpool.py", line 330, in _get_timeout
return Timeout.from_float(timeout)
File "c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\urllib3\util\timeout.py", line 179, in from_float
return Timeout(read=timeout, connect=timeout)
File "c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\urllib3\util\timeout.py", line 103, in __init__
self._connect = self._validate_timeout(connect, "connect")
File "c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\urllib3\util\timeout.py", line 144, in _validate_timeout
raise ValueError(
ValueError: Timeout value connect was Timeout(connect=100, read=100, total=None), but it must be an int, float or None.
我有什么方法可以在我的 python venv 中将此代码发送到 运行?
我猜你是运行宁dropbox-sdk-pythonpython包。
这种错误似乎与 thread.
中解释的依赖项版本有关
因此请确保所有依赖项都具有基于 requirements.txt 文件的正确版本。
要检查所有已安装依赖项的版本运行,请在激活 virtualenv 的情况下执行以下命令。
pip freeze
您确定您使用的是 venv
吗?
如果是,请尝试 运行 不使用 venv
。
并保留您的API 在一个单独的变量中。
并尝试使用 pip uninstall dropbox
卸载 Dropbox 然后安装它pip install dropbox
.
我目前正在尝试使用 python 中的 API 密钥连接到我的保管箱帐户。当我 运行 它不使用虚拟环境时,我可以从下面的代码中获取我的个人资料信息。
import dropbox
d = dropbox.Dropbox("myAPIkey")
print(d.users_get_current_account())
但是当我 运行 使用我的 python venv 的代码时,我得到这个错误
Traceback (most recent call last):
File "c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\urllib3\util\timeout.py", line 142, in _validate_timeout
float(value)
TypeError: float() argument must be a string or a number, not 'Timeout'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "d:/Desktop/FYP/FYP-TheBoyes/dropbox_tester.py", line 8, in <module>
print(d.users_get_current_account())
File "c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\dropbox\base.py", line 5216, in users_get_current_account
r = self.request(
File "c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\dropbox\dropbox_client.py", line 321, in request
res = self.request_json_string_with_retry(host,
File "c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\dropbox\dropbox_client.py", line 476, in request_json_string_with_retry
return self.request_json_string(host,
File "c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\dropbox\dropbox_client.py", line 588, in request_json_string
r = self._session.post(url,
File "d:\Desktop\FYP\FYP-Django\venv\lib\site-packages\requests\sessions.py", line 522, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "d:\Desktop\FYP\FYP-Django\venv\lib\site-packages\requests\sessions.py", line 475, in request
resp = self.send(prep, **send_kwargs)
File "d:\Desktop\FYP\FYP-Django\venv\lib\site-packages\requests\sessions.py", line 596, in send
r = adapter.send(request, **kwargs)
File "d:\Desktop\FYP\FYP-Django\venv\lib\site-packages\requests\adapters.py", line 413, in send
resp = conn.urlopen(
File "c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\urllib3\connectionpool.py", line 687, in urlopen
timeout_obj = self._get_timeout(timeout)
File "c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\urllib3\connectionpool.py", line 330, in _get_timeout
return Timeout.from_float(timeout)
File "c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\urllib3\util\timeout.py", line 179, in from_float
return Timeout(read=timeout, connect=timeout)
File "c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\urllib3\util\timeout.py", line 103, in __init__
self._connect = self._validate_timeout(connect, "connect")
File "c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\urllib3\util\timeout.py", line 144, in _validate_timeout
raise ValueError(
ValueError: Timeout value connect was Timeout(connect=100, read=100, total=None), but it must be an int, float or None.
我有什么方法可以在我的 python venv 中将此代码发送到 运行?
我猜你是运行宁dropbox-sdk-pythonpython包。
这种错误似乎与 thread.
因此请确保所有依赖项都具有基于 requirements.txt 文件的正确版本。
要检查所有已安装依赖项的版本运行,请在激活 virtualenv 的情况下执行以下命令。
pip freeze
您确定您使用的是 venv
吗?
如果是,请尝试 运行 不使用 venv
。
并保留您的API 在一个单独的变量中。
并尝试使用 pip uninstall dropbox
卸载 Dropbox 然后安装它pip install dropbox
.