首页 \ 问答 \ 删除所有virtualenv并从头开始(Delete all virtualenv and start from scratch)

删除所有virtualenv并从头开始(Delete all virtualenv and start from scratch)

我曾经使用macport,最近切换到自制软件。 使用自制软件安装的python版本清理完所有的macports环境后,我做了pip install virtualenv。

$virtualenv test --no-site-packages
Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in <module>
    working_set.require(__requires__)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
    raise DistributionNotFound(req)  # XXX put more info here
pkg_resources.DistributionNotFound: virtualenv==1.9.1

我还检查了系统中可用的virtualenv,看起来有点令人困惑

$virtualenv
virtualenv      virtualenv-2.6  

所以我卸载我安装的,然后尝试重新安装:

Requirement already satisfied (use --upgrade to upgrade): virtualenv in /usr/local/lib/python2.7/site-packages
-bash: syntax error near unexpected token `('

我检查了/ usr / local / bin中结构的样子:我不认为这些virtualenv(s)中的任何一个都是符号链接:

-rwxr-xr-x    1 root  wheel       276 Mar 12  2013 virtualenv
-rwxr-xr-x    1 root  wheel       284 Mar 12  2013 virtualenv-2.6

如何删除所有virtualenv,并从头开始?


I used to use macport and recently switch to homebrew. After cleaning up all the macports enviornments using python version installed by homebrew I did pip install virtualenv.

$virtualenv test --no-site-packages
Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in <module>
    working_set.require(__requires__)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
    raise DistributionNotFound(req)  # XXX put more info here
pkg_resources.DistributionNotFound: virtualenv==1.9.1

I also check what virtualenv are available in the system, it was bit confusing to see

$virtualenv
virtualenv      virtualenv-2.6  

SO I uninstall what I installed and then tried to do a reinstall:

Requirement already satisfied (use --upgrade to upgrade): virtualenv in /usr/local/lib/python2.7/site-packages
-bash: syntax error near unexpected token `('

I checked how the structure looks like in /usr/local/bin: I don't think any of these virtualenv(s) are symlinks:

-rwxr-xr-x    1 root  wheel       276 Mar 12  2013 virtualenv
-rwxr-xr-x    1 root  wheel       284 Mar 12  2013 virtualenv-2.6

How can I delete all virtualenv, and start from scratch?


原文:https://stackoverflow.com/questions/19348077
更新时间:2023-04-27 21:04

最满意答案

我不明白你的意思是“不知道长度”,如果你传递每个缓冲区的大小和缓冲区的数量作为输入参数,那么你就知道每个所需的长度。

也许这不是最好的,但这将是我的方式。

首先声明全局缓冲区和线程。

static void ** buffer;
pthread_t tid[2];

这里描述了线程如何工作。 第一个缓冲区将为数据分配前两个子缓冲区。 第二个将与其他两个相同。

void *assignBuffer(void *threadid) {

    pthread_t id = pthread_self();

    if (pthread_equal(id, tid[0])) {
        strcpy(buffer[0], "foo");
        strcpy(buffer[1], "bar");
    } else {
        strcpy(buffer[2], "oof");
        strcpy(buffer[3], "rab");
    }
    return NULL;
}
  1. 将程序args从字符串转换为整数。
  2. 这里我们为缓冲区分配未知类型的数组。
  3. 这里我们为每个缓冲区分配大小(以字节为单位)
  4. 最后我们创建工作线程。 重要的是它们会同时运行。
  5. 等到所有线程完成他们的工作。
  6. 简单的打印缓冲区内容

好的,这是代码。

int main(int argc, char **argv) {
    //1
    int bufferSize = atoi(argv[1]);
    int buffersAmount = atoi(argv[2]);

    //2
    buffer = malloc(sizeof(void *)*buffersAmount);

    //3
    int i;
    for (i = 0; i < buffersAmount; ++i) {
        buffer[i] = malloc(bufferSize);
    }

    //4
    i = 0;
    while (i < 2) {
        pthread_create(&tid[i], NULL, &assignBuffer, NULL);
        ++i;
    }

    //5
    for (i = 0; i < 2; i++)
        pthread_join(tid[i], NULL);

    //6
    for (i = 0; i < 4; ++i) {
        printf("%d %s\n", i, (char*)buffer[i]);
    }
    for (i = 0; i < buffersAmount; ++i) {
        free(buffer[i]);
    }
    return 0;
}

随意问你是否理解不对,也对我的英语不好意思,这不是我的母语。


I don't understand what do you mean by "without knowing length", if you pass size of each buffer and number of buffers as input parameters then you know every required length.

Maybe this is not the best, but that would be my way.

First declare global buffer and threads.

static void ** buffer;
pthread_t tid[2];

Here is described how the threads will work. First buffer will assign with data first two sub-buffers. Second will do the same with the other two.

void *assignBuffer(void *threadid) {

    pthread_t id = pthread_self();

    if (pthread_equal(id, tid[0])) {
        strcpy(buffer[0], "foo");
        strcpy(buffer[1], "bar");
    } else {
        strcpy(buffer[2], "oof");
        strcpy(buffer[3], "rab");
    }
    return NULL;
}
  1. Converting program args from string to integer.
  2. Here we assign buffer with arrays of unknown type.
  3. Here we assign each buffer with his size in bytes.
  4. Finally we create working threads. The important thing is that they will run simultaneously.
  5. Waiting until all threads done their job.
  6. Simple print buffer contents.

Ok, here is the code.

int main(int argc, char **argv) {
    //1
    int bufferSize = atoi(argv[1]);
    int buffersAmount = atoi(argv[2]);

    //2
    buffer = malloc(sizeof(void *)*buffersAmount);

    //3
    int i;
    for (i = 0; i < buffersAmount; ++i) {
        buffer[i] = malloc(bufferSize);
    }

    //4
    i = 0;
    while (i < 2) {
        pthread_create(&tid[i], NULL, &assignBuffer, NULL);
        ++i;
    }

    //5
    for (i = 0; i < 2; i++)
        pthread_join(tid[i], NULL);

    //6
    for (i = 0; i < 4; ++i) {
        printf("%d %s\n", i, (char*)buffer[i]);
    }
    for (i = 0; i < buffersAmount; ++i) {
        free(buffer[i]);
    }
    return 0;
}

Feel free to ask if you don't understand something, also sorry for my english it is not my native language.

相关问答

更多
  • 因为你可能用完了堆栈空间。 当您全局声明一个数组时,它会在data / Bss段中分配( 注意这是实现细节 ) 然而,当你在main()声明一个数组时,它会在堆栈上本地创建( 同样是一个实现细节 ) 由于您要分配的数组很大( 1000 X 10000 ),因此可能会耗尽堆栈空间。 Codechef足够智能来检测这个问题,因此它拒绝使用main()中的数组作为错误答案的代码。 Because you probably run out of stack space. When you declare an ar ...
  • 您尚未在原始数组的每个索引处创建数组。 而不是这个: for (int i = 0; i < columns; i++) { for (int j = 0; j < twoDArray[i].length; j++) { twoDArray[i][j] = stdin.nextDouble(); } } 尝试这个: for (int i = 0; i < columns; i++) { System.out.print("Please enter the numbe ...
  • 您可以打开这两个文件,读取第一行以查看时间戳是什么,然后从具有较早时间戳的文件中读取行,直到它不再具有较早的时间戳或结束。 如果是by-minute.csv : 1394589660,minute 1 1394589720,minute 2 这是by-second.csv : 1394589659,second -1 1394589660,second 0 1394589661,second 1 1394589662,second 2 1394589663,second 3 1394589664,seco ...
  • 内存管理器确实维护有关每个已分配内存块的元数据。 除了块的大小之外,这可能还包含信息。 实现此目的的一种常见方式是将元数据存储在用户程序用于引用块的内存地址下方的内存中。 因此,如果对malloc的调用返回地址p ,并且元数据包含n个字节,则元数据将存储在地址pn到p-1 。 The memory manager does indeed maintain metadata about each allocated block of memory. This will likely contain infor ...
  • 由于输入文件是面向行的,因此应该使用getline (C ++等价或C fgets)读取一行,然后使用istringstream将行解析为整数。 由于您不知道大小,您应该使用矢量,并始终控制所有行具有相同的大小,并且行数与列数相同。 最后但并非最不重要的一点,您应该在读取之后立即测试eof ,而不是在循环开始时测试。 代码变为: #include #include #include #include #include
  • 你可以使用np.einsum - np.einsum('ij,ij->i',belong,angles) 你也可以使用np.bincount ,就像这样 - idx,_ = np.where(belong) out = np.bincount(idx,angles[belong]) 样品运行 - In [32]: belong Out[32]: array([[ True, True, True, False, True], [False, False, False, True, ...
  • 我不明白你的意思是“不知道长度”,如果你传递每个缓冲区的大小和缓冲区的数量作为输入参数,那么你就知道每个所需的长度。 也许这不是最好的,但这将是我的方式。 首先声明全局缓冲区和线程。 static void ** buffer; pthread_t tid[2]; 这里描述了线程如何工作。 第一个缓冲区将为数据分配前两个子缓冲区。 第二个将与其他两个相同。 void *assignBuffer(void *threadid) { pthread_t id = pthread_self(); ...
  • 好吧,万一有人面临同样的问题:找到解决方案。 或者我应该说发现了一个错误? 问题在于foreach ($inCart as $inCart1) 。 必须替换为foreach ($inCart as &$inCart1)才能更改循环中的数组值。 另一种方式,它只是读取值,位不能改变它们。 Ok, in case someone faces the same problem: found a solution. Or should I say found a mistake? The problem was w ...
  • 注意: 从措辞来看,这似乎是一个功课问题。 因此,我不会发布任何直接代码。 您的矩阵保证是方形的 ,这意味着您将拥有与列相同的行 数 。 这意味着您只需要扫描第一行,以便知道需要多少行和多少列。 我们假设您的矩阵将存储在.csv(逗号分隔变量)文件中。 你的数据是 n1, n2 n3, n4 只需将文件作为纯文本读取,计算在行结束前找到的分隔符数。 在这种情况下,您在第一行中找到1个逗号,这显然意味着您有2个条目,因此有2列2行; 如果你有3个逗号,你将有4个条目,因此4列4行。 n1, n2, n3, n ...
  • 您的数据看起来不像是属于二维数组或列表。 如果是我,我会创建对数据有意义的数据结构。 如果必须使用列表列表: List> cheese = new ArrayList>(); cheese.add(Arrays.asList("cheddar", "swiss", "pepperjack")); cheese.add(Arrays.asList("sliced", "cubed", "block")); String myFavorite = chees ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。