Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Can';t在Google Drive文件夹中创建虚拟环境_Python_Powershell_Virtualenv_Drive - Fatal编程技术网

Python Can';t在Google Drive文件夹中创建虚拟环境

Python Can';t在Google Drive文件夹中创建虚拟环境,python,powershell,virtualenv,drive,Python,Powershell,Virtualenv,Drive,我正在使用谷歌硬盘保存我的代码项目的副本,以防我的电脑死机(我也在使用GitHub,但不是在一些私人项目上) 但是,当我尝试使用virtualenv创建虚拟环境时,出现以下错误: PS C:\users\fchatter\google drive> virtualenv env New python executable in C:\users\fchatter\google drive\env\Scripts\python.exe ERROR: The executable "C:\us

我正在使用谷歌硬盘保存我的代码项目的副本,以防我的电脑死机(我也在使用GitHub,但不是在一些私人项目上)

但是,当我尝试使用
virtualenv
创建虚拟环境时,出现以下错误:

PS C:\users\fchatter\google drive> virtualenv env
New python executable in C:\users\fchatter\google drive\env\Scripts\python.exe
ERROR: The executable "C:\users\fchatter\google drive\env\Scripts\python.exe" could not be run: [Error 5] Access is denied
我尝试过的事情:

  • 我认为这是因为venv的路径包含空格,但该命令适用于其他带有空格的路径。我还尝试按照
    virtualenv
    文档中的建议安装win32api库,但没有成功

  • 以管理员身份运行PowerShell


有没有办法解决这个问题?我目前的解决办法是在Google Drive之外创建venv,这虽然有效,但并不方便。

不要在云同步文件夹中设置虚拟环境,也不应该在这样的文件夹中运行python脚本。这是个坏主意。它们不是用于版本控制的。对文件夹的写入访问(修改文件)受到限制,因为在您的情况下,Google drive会定期同步文件夹,这几乎总是会阻止对文件夹的独占写入访问

TLDR;同步文件时不可能修改文件


我建议您坚持使用git进行版本控制。

在遇到同样的问题并玩了几个小时之后,这似乎是不可能的。它与文件/文件夹名称中的空格无关。我已经测试过了。Google Drive Stream似乎在一段时间后对文件/文件夹执行了一些操作,这使得python失去了对文件的路径。例如,您可以将python模块克隆到Google驱动器流文件夹中,执行“pip install-e./”,它将在virtevn中工作几分钟,例如将其导入python shell。但几分钟后,您无法再导入模块。我怀疑Google Drive Stream与所有文件系统调用都不完全兼容,python正在使用其中一个调用。

您是否检查了
python.exe
的权限设置?如果出于任何原因,您的用户帐户没有读取/执行权限,它将无法工作,如错误所示。如果您需要私人存储库,请再次检查Bitbucket,而不是使用Google Drive。他们在免费工厂提供私人回购协议,但这并不能提供答案。问题不在于如何根据最佳实践设置项目,而是让virtualenv在Google Drive中工作。它失败的原因是路径中存在空间,而virtualenv不支持这一点。这与谷歌硬盘无关。