在Visual Studio 2013上遇到,但它可以与任何版本重现.
我从github克隆了协议缓冲库,在它上面运行了CMake-gui(我将所有内容都保留为默认值,因此它是静态版本),只构建libprotobuf(其他项目由于某种原因失败,cmd.exe错误,可能有事情要做有测试,但libprotobuf构建良好).
我的项目使用在mapbox矢量tile规范的github上找到的.proto文件生成的标题.
当我链接时,我首先有这个错误
Error 1 error C4996: 'std::_Copy_impl': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators' s:\program files (x86)\microsoft visual studio 12.0\vc\include\xutility
我尝试-D_SCL_SECURE_NO_WARNINGS
在其他命令行参数中禁用它,但后来我有其他错误:
Error 1 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj S:\eiogit3\misc-projs\mapload\mapload\libprotobufd.lib(common.obj)
c++ protocol-buffers visual-studio visual-c++ visual-studio-2013
这基本上与[SO]: C2491: 'std::numpunct<_Elem>::id' : Define of dllimport static data member not allowed [close] 相同,但考虑以下事实:
请不要将其关闭或将其标记为重复项(至少,在没有仔细阅读和理解的情况下)。
主要.cpp:
#include <sstream>
//#define THROW_C2491
#if defined(THROW_C2491)
typedef int CharType;
#else
typedef char CharType;
#endif
int main() {
std::basic_stringstream<CharType> stream;
CharType c = 0x41;
stream << c;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
代码稍作修改(简化),如果 THROW_C2491
定义则无法编译:
Run Code Online (Sandbox Code Playgroud)xlocnum(294): error C2491: 'std::numpunct<_Elem>::id': definition of dllimport static data member not allowed
输出:
Run Code Online (Sandbox Code Playgroud)xlocnum(294): error C2491: 'std::numpunct<_Elem>::id': definition of …
[PyPI]: pywin32 226已于20191110发布。
它适用于大多数Python安装(例如适用于从Python下载的官方版本),但不适用于虚拟环境(例如 使用VirtualEnv ( v16.7.7 )创建,以及(基于进一步研究)Python的venv)。
我使用Python v3.8 .0和v3.7 .3作为实验室老鼠。这是前者的输出:
Run Code Online (Sandbox Code Playgroud)[cfati@CFATI-5510-0:e:\Work\Dev\StackOverflow\q058805040]> "e:\Work\Dev\VEnvs\py_064_03.08.00_test0\Scripts\python.exe" -c "import win32api" Fatal Python error: init_import_size: Failed to import the site module Python runtime state: initialized Traceback (most recent call last): File "e:\Work\Dev\VEnvs\py_064_03.08.00_test0\lib\site.py", line 769, in <module> main() File "e:\Work\Dev\VEnvs\py_064_03.08.00_test0\lib\site.py", line 746, in main paths_in_sys = addsitepackages(paths_in_sys) File "e:\Work\Dev\VEnvs\py_064_03.08.00_test0\lib\site.py", line …
当我使用mysql_pool
fromaiomysql
更新一条数据时,第一次和第二次是一样的。
class Test(object):\n async def _pool(self):\n self.pool = await aiomysql.create_\xc3\xa7(**mysql_options)\n\n async def get_one(self, sql, param=None):\n await self.cur.execute(sql, param)\n result = await self.cur.fetchone()\n return result\n\n async def get(self):\n self.conn = await self.pool.acquire()\n self.cur = await self.conn.cursor(DictCursor)\n sql = \'\'\'select policy from tb_user where id = 2;\'\'\'\n res = await self.get_one(sql)\n print(res)\n await self.cur.close()\n await self.pool.release(self.conn)\n\n @staticmethod\n def update():\n import pymysql\n coon = pymysql.connect(host=\'127.0.0.1\',\n port=3306,\n user=mysql_options[\'user\'],\n autocommit=True,\n password=mysql_options[\'password\'],\n database=mysql_options[\'db\'])\n cursor = coon.cursor()\n sql = \'\'\'update tb_user set …
Run Code Online (Sandbox Code Playgroud) 我必须强调的PyCharm 社区版这也没有任何Django的集成(v 2016年3月2日在提问时间,但仍然有效).
我谷歌我的问题和(令人惊讶的是)我没有得到任何答案(当然我不排除可能有一些的可能性,但我只是错过了他们).
问题很简单,在PyCharm中,可以通过简单的鼠标右键单击(从上下文菜单中)运行(调试)单元测试(TestCase或其中一种方法),如下图所示:
不幸的是,这产生了一个例外:
Run Code Online (Sandbox Code Playgroud)Traceback (most recent call last): File "C:\Install\PyCharm Community Edition\2016.3.2\helpers\pycharm\utrunner.py", line 254, in <module> main() File "C:\Install\PyCharm Community Edition\2016.3.2\helpers\pycharm\utrunner.py", line 232, in main module = loadSource(a[0]) File "C:\Install\PyCharm Community Edition\2016.3.2\helpers\pycharm\utrunner.py", line 65, in loadSource module = imp.load_source(moduleName, fileName) File "E:\Work\Dev\Django\Tutorials\proj0\src\polls\tests.py", line 7, in <module> from polls.models import Question File "E:\Work\Dev\Django\Tutorials\proj0\src\polls\models.py", line 9, in <module> class Question(models.Model): File "E:\Work\Dev\Django\Tutorials\proj0\src\polls\models.py", line 10, …
我需要在 Windows 平台下从我的 C++ 项目中调用实现为 Python (3.6) 函数的管道。来自文件“ experiment_test.py ”的函数“ function_name ”将文本字符串作为输入参数,并返回另一个文本字符串作为结果。我尝试了下面的代码,但它不能正常工作 - 库shutil、codecs、makedirs等中的python 函数不起作用。
C++ 代码(减少):
std::string Text,Result;
PyObject *pName, *pModule, *pDict, *pFunc, *pArgs, *pValue;
Py_Initialize();
pName = PyUnicode_FromString("experiment_test");
pModule = PyImport_Import(pName);
pDict = PyModule_GetDict(pModule);
pFunc = PyDict_GetItemString(pDict, "function_name");
pArgs = PyTuple_New(1);
pValue = PyUnicode_FromString(Text.c_str());
PyTuple_SetItem(pArgs, 0, pValue);
if (PyCallable_Check(pFunc))
{
pValue = PyObject_CallObject(pFunc, pArgs);
if (pValue != NULL)
{
Result = PyUnicode_AsUTF8(pValue);
Py_DECREF(pValue);
}
else return false;
}
// ...
Py_Finalize();
Run Code Online (Sandbox Code Playgroud)
Python代码(减少): …
假设我们有x = ['a', 'b']
.
发言内容正在发生什么:
x not in {None, False}
Run Code Online (Sandbox Code Playgroud)
那引起了unhashable type: 'list'
错误?
我找到的解决方法是改为:
x != None and x!= False
Run Code Online (Sandbox Code Playgroud)
但我很困惑,因为从数学上讲,两个布尔表达式都是等价的.
我正在尝试在运行 Windows 10 的计算机上安装 rpy2。我已经安装了 R 3.4.4(64 位)并且它在 RGui 中运行良好。然后我尝试 pip install rpy2,但出现找不到 R 的错误,因此我将 c:\Program Files\R\R-3.4.4\bin\ 添加到我的路径环境变量中。现在当我这样做时
pip install rpy2
Run Code Online (Sandbox Code Playgroud)
我收到一个不同的错误:
命令 '('c:\PROGRA~1\R\R-34~1.4\bin\x64\R', 'CMD', 'config', '--ldflags')' 返回非零退出状态 1
完整的输出如下所示。知道我做错了什么吗?
pip install rpy2
Collecting rpy2
Downloading https://files.pythonhosted.org/packages/88/f7/788e5e1587bc1ab48b5b0467f9c3a08ef5aadbd993ed835559a10e452121/rpy2-2.9.3.tar.gz (193kB)
Complete output from command python setup.py egg_info:
R version 3.4.4 (2018-03-15) -- "Someone to Lean On"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to …
Run Code Online (Sandbox Code Playgroud) 是否可以在 64 位安装中运行 32 位 Cygwin 应用程序?
动机:如64 位 Windows 的 cygwin 1.7.26 中的 rxvt-native 实用程序在哪里?, rxvt-native
,我最喜欢的 Windows 终端模拟器,目前在 64 位 Cygwin 中不可用。我的希望是,就像我可以在 64 位 Linux 发行版上运行 32 位 Linux 应用程序一样,也许我可以在 64 位 Cygwin 上运行 32 位 rxvt。
我尝试将可执行文件从旧电脑的C:\cygwin\bin
目录复制到新电脑的C:\cygwin64\usr\local\bin
目录,但无法运行。
当我运行该进程时,它只是默默地什么都不做。
ldd
告诉我缺少一些依赖项:
$ ldd /usr/local/bin/rxvt-native.exe
ntdll.dll => /cygdrive/c/Windows/SYSTEM32/ntdll.dll (0x7ffcb79b0000)
??? => ??? (0x77a10000)
wow64.dll => /cygdrive/c/Windows/System32/wow64.dll (0x62c20000)
wow64win.dll => /cygdrive/c/Windows/System32/wow64win.dll (0x62c80000)
Run Code Online (Sandbox Code Playgroud)
我尝试cygwin1.dll
从 32 位系统复制该文件,但我不确定如何使其仅可供此进程使用,而不向其他进程隐藏 64 位文件。
我的下一个选择是卸载我的 64 位 cygwin 并重新使用 …
我想从 python 调用一些 c 函数来提高代码的性能。但我无法在网上找到当我使用 ctypes 库调用 C 函数时 GIL 是否被释放。举个简单的例子:
from ctypes import *
fun = cdll.LoadLibrary("libc.so.6")
fun.sleep.argtypes = [c_uint]
fun.sleep(c_uint(5))
Run Code Online (Sandbox Code Playgroud)
GIL 是否在调用期间被释放fun.sleep
?
python ×7
c++ ×3
windows ×3
visual-c++ ×2
32bit-64bit ×1
aio-mysql ×1
ctypes ×1
cygwin ×1
django ×1
dllimport ×1
gil ×1
mysql ×1
pycharm ×1
python-3.x ×1
python-cffi ×1
pywin32 ×1
rpy2 ×1
rxvt ×1
unit-testing ×1
virtualenv ×1