我在 MacOS (10.11) 下遇到过这个问题,但在各种 Linux 下也遇到过同样的问题。我安装了“官方”Python3 包,它进入/Library/Frameworks/Python.framework/Versions/3.4. (注意:以下示例使用 Python 3.4,但问题在 3.5 中仍然存在。如果问题已在 3.6 中解决,由于缺乏管理员权限,我无法访问具有 Python 3.6 的机器。)
我需要虚拟环境,我需要python-config脚本来确定 Python3 使用哪些库,因为我的项目结合了 Python 和 C++ 代码。
如果我用 设置虚拟环境virtualenv,一切都很好:
$ which virtualenv
/Library/Frameworks/Python.framework/Versions/3.4/bin/virtualenv
$ virtualenv --python=$(which python3) vienv
Running virtualenv with interpreter /Library/Frameworks/Python.framework/Versions/3.4/bin/python3
Using base prefix '/Library/Frameworks/Python.framework/Versions/3.4'
[...blabla...]
Installing setuptools, pip, wheel...done.
$ source vienv/bin/activate
(vienv) $ which python-config
/Users/XXXXX/DEV/STANDALONE/misc/python/vienv/bin/python-config
(vienv) $ python-config --libs
-lpython3.4m -ldl -framework CoreFoundation
但是,pyvenv忘记python-config在虚拟环境中设置:
$which pyvenv
/Library/Frameworks/Python.framework/Versions/3.4/bin/pyvenv
$ …我的 virtualenv 目前配置为 python 3.5.0,而我需要使用的包只支持 2.7。我需要一种在我的 virtualenv 中将我的 python 运行时降级到 2.7 的方法。
我确实有两个版本可供使用:第一个在我的 virtualenv 中,第二个在计算机范围内。
(project) me-Air:element me$ python -V
Python 3.5.0
me-Air:element me$ python -V
Python 2.7.10
我创建了一个变量cfg = waterot.cfg,然后waterot.cfg在 pycharm 中创建了一个新文件“”,这会自动创建一个pyvenv.cfg文件,我不知道这是什么,我的代码出现错误,我删除了该pyvenv.cfg文件并从 更改.cfg为.txt。现在,当我运行代码时出现错误No pyvvenv.cfg file
这是有问题的代码
redeemkey = message.author
if redeemkey.startswith('!download'):
    if message.channel.id == 695834994064490658:
        with open ('waterOT.txt', 'rb') as otcfg:
            await message.author.send(file=discord.File(otcfg, 'waterOT.cfg'))
        await message.delete()