小编Aks*_*pta的帖子

在 setuptools 中使用 console_scripts 时出现导入错误

我正在尝试构建一个dnsrep在 Python 中调用的程序,我正在使用 setuptools 以便我可以在dnsrep不使用命令的情况下调用模块python dnsrepsetup.py我写的脚本如下:

from setuptools import setup, find_packages

setup(
    name='dnsrep',
    version='0.1',
    description='Program that gives a reputation score to url\'s\n.',
    entry_points = {
        'console_scripts': ['dnsrep = dnsrep:main']
    },
    zip_safe=True,
)
Run Code Online (Sandbox Code Playgroud)

我使用以下命令安装模块:

python setup.py install
Run Code Online (Sandbox Code Playgroud)

我的模块已注册,但是当我运行它时出现错误:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/bin/dnsrep", line 9, in <module>
    load_entry_point('dnsrep==0.1', 'console_scripts', 'dnsrep')()
  File "build/bdist.macosx-10.6-intel/egg/pkg_resources/__init__.py", line 521, in load_entry_point
  File "build/bdist.macosx-10.6-intel/egg/pkg_resources/__init__.py", line 2632, in load_entry_point
  File "build/bdist.macosx-10.6-intel/egg/pkg_resources/__init__.py", line 2312, in load
  File "build/bdist.macosx-10.6-intel/egg/pkg_resources/__init__.py", line …
Run Code Online (Sandbox Code Playgroud)

python setuptools

5
推荐指数
1
解决办法
2451
查看次数

C 中的内存分配错误

我试图在 GMP 中获得一个大整数的二进制表示。我将 1 和 0 存储在一个名为expBinary的数组中。我使用 malloc 分配大小为“int”的内存,然后在添加新位时使用realloc增加此内存。转换是没有任何问题的完美运行,但是当我尝试后while循环分配使用malloc任何更多的内存,它给我段错误,当我调用同一个代码第二次,第一次给了我不分段错误。我已经检查过并且“expBinary”没有存储任何越界的东西,我已经给出了下面的代码

int binarySize = 0;                                                        
int * expBinary = malloc(sizeof(int));                                 
int i = 0;                                                                  

// Run until exp == 0                                                       
while(mpz_cmp_ui(exp,0) != 0)                                               
{                                                                           
    binarySize++;                                                           
    expBinary = (int*) realloc(expBinary,(binarySize));                     
    // Getting LSB of exp                                                   
    if(mpz_even_p(exp) != 0)                                                
        expBinary[i] = 0;                                                   
    else                                                                    
        expBinary[i] = 1;                                                                                                                                 
    // Incrmenting variables                                                
    i++;                                                                    
    // Dividing exponent by 2                                               
    mpz_tdiv_q_ui(exp,exp,2);                                               
}                                                                           

// This line is giving error
int * temp …
Run Code Online (Sandbox Code Playgroud)

c malloc memory-management gmp realloc

2
推荐指数
1
解决办法
3192
查看次数

标签 统计

c ×1

gmp ×1

malloc ×1

memory-management ×1

python ×1

realloc ×1

setuptools ×1