尝试安装到virtualenv

时间:2018-10-01 06:06:19

标签: python-3.6 pipenv

我正在尝试设置管道以为我的雇主输出一个pipfile。我对此完全陌生,并且缺乏系统知识。请有人可以帮助我调试此错误吗?

当我跑步时:

pipenv install -e

我收到以下错误:

(py3) ➜  ~ git:(master) ✗ pipenv install -e
Creating a virtualenv for this project...
Pipfile: /Users/davidmellor/Pipfile
Using /Users/davidmellor/anaconda/envs/py3/bin/python (3.6.2) to create virtualenv...
⠋Already using interpreter /Users/davidmellor/anaconda/envs/py3/bin/python
Using base prefix '/Users/davidmellor/anaconda/envs/py3'
New python executable in /Users/davidmellor/.local/share/virtualenvs/davidmellor-1NR562gx/bin/python
dyld: Library not loaded: @rpath/libpython3.6m.dylib
  Referenced from: /Users/davidmellor/.local/share/virtualenvs/davidmellor-1NR562gx/bin/python
  Reason: image not found
ERROR: The executable /Users/davidmellor/.local/share/virtualenvs/davidmellor-1NR562gx/bin/python is not functioning
ERROR: It thinks sys.prefix is '/Users/davidmellor' (should be '/Users/davidmellor/.local/share/virtualenvs/davidmellor-1NR562gx')
ERROR: virtualenv is not compatible with this system or executable

Virtualenv location:
Creating a Pipfile for this project...
Traceback (most recent call last):
  File "/Users/davidmellor/anaconda/envs/py3/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/Users/davidmellor/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Users/davidmellor/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Users/davidmellor/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/davidmellor/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/davidmellor/.local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/davidmellor/.local/lib/python3.6/site-packages/pipenv/cli.py", line 435, in install
    selective_upgrade=selective_upgrade,
  File "/Users/davidmellor/.local/lib/python3.6/site-packages/pipenv/core.py", line 1759, in do_install
    pypi_mirror=pypi_mirror,
  File "/Users/davidmellor/.local/lib/python3.6/site-packages/pipenv/core.py", line 639, in ensure_project
    ensure_pipfile(validate=validate, skip_requirements=skip_requirements, system=system)
  File "/Users/davidmellor/.local/lib/python3.6/site-packages/pipenv/core.py", line 288, in ensure_pipfile
    project.create_pipfile(python=python)
  File "/Users/davidmellor/.local/lib/python3.6/site-packages/pipenv/project.py", line 607, in create_pipfile
    required_python = self.which('python')
  File "/Users/davidmellor/.local/lib/python3.6/site-packages/pipenv/core.py", line 115, in which
    p = os.path.join(location, 'bin', command)
  File "/Users/davidmellor/anaconda/envs/py3/lib/python3.6/posixpath.py", line 78, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType

我尝试如下修改我的.bashrc文件中的PATH:

PYTHON_BIN_PATH="$/Users/davidmellor/.local/bin"
PATH="$PATH:$PYTHON_BIN_PATH"

export PATH=$HOME/.composer/vendor/bin

export DJANGO_SETTINGS_MODULE=blog.settings

但是仍然没有运气。

非常感谢您。

1 个答案:

答案 0 :(得分:0)

尝试在pipenv中使用“ pyenv”软件包。

使用brew install pyenv(如果您没有)安装'pyenv'软件包。

使用pyenv install 3.6.2安装python 3.6.2。在您的情况下,您使用的是anaconda,因此您还可以安装要使用的任何anaconda版本。 使用pyenv install --list查看python可用版本的列表

然后,将新安装的python版本导出到PATH

export PATH=${PYENV_PYTHON_VERSIONS_HOME}/3.6.2/bin

“密码锁”中的现在指定相同版本。

[requires] python_version = "3.6.2"

最后,运行删除先前的virtualenv并再次重建。

pipenv --rm

pipenv install --dev