PIP和virtualenv的麻烦 [英] trouble with PIP and virtualenv

查看:91
本文介绍了PIP和virtualenv的麻烦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我在桌面上创建一个文件夹并在终端上运行"virtualenv venv"时,一切正常.但是,当我尝试在文档"文件夹中创建一个文件夹并运行"virtualenv venv"时,出现以下错误? 有什么建议吗?

Whenever i create a folder on my desktop and run "virtualenv venv" on terminal, everything works fine. However when i try to create a folder in my "documents" folder and run "virtualenv venv" i get this error below? any suggestions why?

Andrews-MacBook-Pro:Python Virtualenv AndrewParkPhotography$ cd myproject
Andrews-MacBook-Pro:myproject AndrewParkPhotography$ ls
Andrews-MacBook-Pro:myproject AndrewParkPhotography$ virtualenv venv
New python executable in venv/bin/python
Installing setuptools............done.
Installing pip...
  Error [Errno 2] No such file or directory while executing command /Users/AndrewParkPho...env/bin/easy_install /Library/Python/2.7/...pport/pip-1.1.tar.gz
...Installing pip...done.
Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 8, in <module>
    load_entry_point('virtualenv==1.7.1.2', 'console_scripts', 'virtualenv')()
  File "/Library/Python/2.7/site-packages/virtualenv.py", line 928, in main
    never_download=options.never_download)
  File "/Library/Python/2.7/site-packages/virtualenv.py", line 1042, in create_environment
    install_pip(py_executable, search_dirs=search_dirs, never_download=never_download)
  File "/Library/Python/2.7/site-packages/virtualenv.py", line 640, in install_pip
    filter_stdout=_filter_setup)
  File "/Library/Python/2.7/site-packages/virtualenv.py", line 966, in call_subprocess
    cwd=cwd, env=env)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 672, in __init__
    errread, errwrite)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1202, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

推荐答案

在此处找到答案(在没有空格的路径中创建您的virtualenv环境.这就是为什么它发生的原因:

create your virtualenv environment within a path without spaces. This is why it is happening:

创建环境时,它会设置一个bin目录.在该bin目录中,所有与环境有关的可执行文件.有些是脚本.如您所知,hashbang用来告诉系统使用什么解释器来运行脚本.您可能经常在脚本顶部看到此信息:

When you create an environment, it sets up a bin directory. In that bin directory are all the executables relating to the environment. Some are scripts. As you may know, hashbangs are used to tell the system what interpreter to use to run the script. You may see this at the top of scripts often:

#!/usr/bin/env python

如果脚本位于/tmp/test.py,则指示系统运行此命令来执行脚本:

If the script is at /tmp/test.py, that tells the system to run this command to execute the script:

/usr/bin/env python /tmp/test.py

以您为例,virtualenv正在创建如下脚本:

In your case, virtualenv is creating scripts like this:

#!/tmp/oh no/bin/python

当系统尝试执行该命令时,它将尝试使用参数no/bin/python和/tmp/test.py执行命令/tmp/oh. /tmp/oh不存在,所以失败了

When the system tries to execute that, it will try to execute the command /tmp/oh with the arguments no/bin/python and /tmp/test.py. /tmp/oh does not exist, so it fails

这篇关于PIP和virtualenv的麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆