最新消息:20210917 已从crifan.com换到crifan.org

【已解决】pipenv install出错:TypeError: expected str, bytes or os.PathLike object, not NoneType

TypeError crifan 1076浏览 0评论
折腾:
【记录】Mac中用Python去模拟百度登陆
期间,pipenv又出了问题:
➜  EmulateBaiduLogin pipenv install requests
Creating a virtualenv for this project...
Pipfile: /Users/crifan/dev/dev_root/projects/BaiduEmulateLogin/python/EmulateBaiduLogin/Pipfile
Using /usr/local/bin/python3.6m (3.6.4) to create virtualenv...
⠋^Environment creation aborted.
Error:  An error occurred while removing /Users/crifan/.local/share/virtualenvs/EmulateBaiduLogin-NWdfeAzC!
[Errno 2] No such file or directory: 'python3'
^C
➜  EmulateBaiduLogin
➜  EmulateBaiduLogin pipenv install requests
Creating a virtualenv for this project...
Pipfile: /Users/crifan/dev/dev_root/projects/BaiduEmulateLogin/python/EmulateBaiduLogin/Pipfile
Using /usr/local/bin/python3.6m (3.6.4) to create virtualenv...
⠋^Environment creation aborted.
Error:  An error occurred while removing /Users/crifan/.local/share/virtualenvs/EmulateBaiduLogin-NWdfeAzC!
[Errno 2] No such file or directory: 'sre_constants.py'
➜  EmulateBaiduLogin
➜  EmulateBaiduLogin pipenv instal
Usage: pipenv [OPTIONS] COMMAND [ARGS]...

Error: No such command "instal".

Did you mean one of these?
    install
    uninstall
➜  EmulateBaiduLogin pipenv install
Creating a virtualenv for this project...
Pipfile: /Users/crifan/dev/dev_root/projects/BaiduEmulateLogin/python/EmulateBaiduLogin/Pipfile
Using /usr/local/bin/python3.6m (3.6.4) to create virtualenv...
⠋^Environment creation aborted.
Error:  An error occurred while removing /Users/crifan/.local/share/virtualenvs/EmulateBaiduLogin-NWdfeAzC!
[Errno 2] No such file or directory: 'python3.6'
➜  EmulateBaiduLogin
➜  EmulateBaiduLogin
➜  EmulateBaiduLogin pipenv --rm
No virtualenv has been created for this project yet!
➜  EmulateBaiduLogin pipenv shell
Creating a virtualenv for this project...
Pipfile: /Users/crifan/dev/dev_root/projects/BaiduEmulateLogin/python/EmulateBaiduLogin/Pipfile
Using /usr/local/bin/python3.6m (3.6.4) to create virtualenv...
⠋Running virtualenv with interpreter /usr/local/bin/python3.6m
Using base prefix '/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6'
New python executable in /Users/crifan/.local/share/virtualenvs/EmulateBaiduLogin-NWdfeAzC/bin/python3.6
Also creating executable in /Users/crifan/.local/share/virtualenvs/EmulateBaiduLogin-NWdfeAzC/bin/python
Installing setuptools, pip, wheel...
  Complete output from command /Users/crifan/.local...dfeAzC/bin/python3.6 - setuptools pip wheel:
  Collecting setuptools
  Downloading https://files.pythonhosted.org/packages/e7/16/da8cb8046149d50940c6110310983abb359bbb8cbc3539e6bef95c29428a/setuptools-40.6.2-py2.py3-none-any.whl (573kB)
Exception:
Traceback (most recent call last):
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/_vendor/urllib3/response.py", line 302, in _error_catcher
    yield
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/_vendor/urllib3/response.py", line 384, in read
    data = self._fp.read(amt)
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/_vendor/cachecontrol/filewrapper.py", line 60, in read
    data = self.__fp.read(amt)
  File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 449, in read
    n = self.readinto(b)
  File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py", line 493, in readinto
    n = self.fp.readinto(b)
  File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/socket.py", line 586, in readinto
    return self._sock.recv_into(b)
  File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 1009, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 871, in read
    return self._sslobj.read(len, buffer)
  File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 631, in read
    v = self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/commands/install.py", line 324, in run
    requirement_set.prepare_files(finder)
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/req/req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/req/req_set.py", line 620, in _prepare_file
    session=self.session, hashes=hashes)
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/download.py", line 821, in unpack_url
    hashes=hashes
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/download.py", line 659, in unpack_http_url
    hashes)
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/download.py", line 882, in _download_http_url
    _download_url(resp, link, content_file, hashes)
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/download.py", line 603, in _download_url
    hashes.check_against_chunks(downloaded_chunks)
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/utils/hashes.py", line 46, in check_against_chunks
    for chunk in chunks:
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/download.py", line 571, in written_chunks
    for chunk in chunks:
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/utils/ui.py", line 139, in iter
    for x in it:
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/download.py", line 560, in resp_read
    decode_content=False):
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/_vendor/urllib3/response.py", line 436, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/_vendor/urllib3/response.py", line 401, in read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
  File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.py", line 99, in __exit__
    self.gen.throw(type, value, traceback)
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/virtualenv_support/pip-9.0.3-py2.py3-none-any.whl/pip/_vendor/urllib3/response.py", line 307, in _error_catcher
    raise ReadTimeoutError(self._pool, None, 'Read timed out.')
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/virtualenv.py", line 2349, in <module>
    main()
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/virtualenv.py", line 712, in main
    symlink=options.symlink)
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/virtualenv.py", line 953, in create_environment
    download=download,
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/virtualenv.py", line 904, in install_wheel
    call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/virtualenv.py", line 796, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /Users/crifan/.local...dfeAzC/bin/python3.6 - setuptools pip wheel failed with error code 2

Virtualenv location:
Traceback (most recent call last):
  File "/Users/crifan/Library/Python/3.6/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/pipenv/cli.py", line 664, in shell
    three=three, python=python, fancy=fancy, shell_args=shell_args, pypi_mirror=pypi_mirror
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/pipenv/core.py", line 2141, in do_shell
    ensure_project(three=three, python=python, validate=False, pypi_mirror=pypi_mirror)
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/pipenv/core.py", line 614, in ensure_project
    path_to_python = which('python') or which('py')
  File "/Users/crifan/Library/Python/3.6/lib/python/site-packages/pipenv/core.py", line 115, in which
    p = os.path.join(location, 'bin', command)
  File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/posixpath.py", line 78, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType
pipenv upgrade
去参考:
Pipenv: Python Dev Workflow for Humans — pipenv 2018.10.14.dev0 documentation
windows – Why can’t I update pipenv to latest version? – Stack Overflow
➜  EmulateBaiduLogin pip install --upgrade pipenv
Collecting pipenv
  Downloading https://files.pythonhosted.org/packages/c3/e7/140613195a136c07be4c85db87400a130932093f1ddb1a8ca3593324a735/pipenv-2018.10.13-py2-none-any.whl (5.2MB)
    100% |████████████████████████████████| 5.2MB 13kB/s
Requirement not upgraded as not directly required: setuptools>=36.2.1 in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (39.0.1)
Requirement not upgraded as not directly required: virtualenv in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (16.0.0)
Requirement not upgraded as not directly required: enum34; python_version < "3" in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (1.1.6)
Requirement not upgraded as not directly required: pip>=9.0.1 in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (10.0.1)
Collecting typing; python_version < "3.5" (from pipenv)
  Downloading https://files.pythonhosted.org/packages/cc/3e/29f92b7aeda5b078c86d14f550bf85cff809042e3429ace7af6193c3bc9f/typing-3.6.6-py2-none-any.whl
Requirement not upgraded as not directly required: certifi in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (2018.8.24)
Requirement not upgraded as not directly required: virtualenv-clone>=0.2.5 in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (0.3.0)
matplotlib 1.3.1 requires nose, which is not installed.
matplotlib 1.3.1 requires tornado, which is not installed.
pyopenssl 18.0.0 has requirement six>=1.5.2, but you'll have six 1.4.1 which is incompatible.
Installing collected packages: typing, pipenv
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/typing.pyc'
Consider using the `--user` option or check the permissions.

You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
然后加上–user
➜  EmulateBaiduLogin pip install --upgrade pipenv --user
Collecting pipenv
  Using cached https://files.pythonhosted.org/packages/c3/e7/140613195a136c07be4c85db87400a130932093f1ddb1a8ca3593324a735/pipenv-2018.10.13-py2-none-any.whl
Requirement not upgraded as not directly required: setuptools>=36.2.1 in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (39.0.1)
Requirement not upgraded as not directly required: virtualenv in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (16.0.0)
Requirement not upgraded as not directly required: enum34; python_version < "3" in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (1.1.6)
Requirement not upgraded as not directly required: pip>=9.0.1 in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (10.0.1)
Collecting typing; python_version < "3.5" (from pipenv)
  Using cached https://files.pythonhosted.org/packages/cc/3e/29f92b7aeda5b078c86d14f550bf85cff809042e3429ace7af6193c3bc9f/typing-3.6.6-py2-none-any.whl
Requirement not upgraded as not directly required: certifi in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (2018.8.24)
Requirement not upgraded as not directly required: virtualenv-clone>=0.2.5 in /Users/crifan/Library/Python/2.7/lib/python/site-packages (from pipenv) (0.3.0)
matplotlib 1.3.1 requires nose, which is not installed.
matplotlib 1.3.1 requires tornado, which is not installed.
pyopenssl 18.0.0 has requirement six>=1.5.2, but you'll have six 1.4.1 which is incompatible.
Installing collected packages: typing, pipenv
  Found existing installation: pipenv 11.10.0
    Uninstalling pipenv-11.10.0:
      Successfully uninstalled pipenv-11.10.0
Successfully installed pipenv-2018.10.13 typing-3.6.6
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
➜  EmulateBaiduLogin pip show pipenv
Name: pipenv
Version: 2018.10.13
Summary: Python Development Workflow for Humans.
Home-page: https://github.com/pypa/pipenv
Author: Kenneth Reitz
Author-email: me@kennethreitz.org
License: MIT
Location: /Users/crifan/Library/Python/2.7/lib/python/site-packages
Requires: setuptools, virtualenv, enum34, pip, typing, certifi, virtualenv-clone
Required-by:
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
然后即可就好了:
➜  EmulateBaiduLogin pipenv install
Creating a virtualenv for this project...
Pipfile: /Users/crifan/dev/dev_root/projects/BaiduEmulateLogin/python/EmulateBaiduLogin/Pipfile
Using /usr/local/bin/python3.6m (3.6.4) to create virtualenv...
⠋Running virtualenv with interpreter /usr/local/bin/python3.6m
Using base prefix '/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6'
New python executable in /Users/crifan/.local/share/virtualenvs/EmulateBaiduLogin-NWdfeAzC/bin/python3.6
Also creating executable in /Users/crifan/.local/share/virtualenvs/EmulateBaiduLogin-NWdfeAzC/bin/python
Installing setuptools, pip, wheel...done.
Setting project for EmulateBaiduLogin-NWdfeAzC to /Users/crifan/dev/dev_root/projects/BaiduEmulateLogin/python/EmulateBaiduLogin

Virtualenv location: /Users/crifan/.local/share/virtualenvs/EmulateBaiduLogin-NWdfeAzC
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Updated Pipfile.lock (5b5554)!
Installing dependencies from Pipfile.lock (5b5554)...
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 — 00:00:00
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
【总结】
此处pipenv install环境有问题。
去用:
pip install --upgrade pipenv
升级到最新版后,就正常了。

转载请注明:在路上 » 【已解决】pipenv install出错:TypeError: expected str, bytes or os.PathLike object, not NoneType

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
90 queries in 0.209 seconds, using 23.37MB memory