如何在IronPython

时间:2016-09-20 13:21:46

标签: python pandas numpy ironpython python.net

我是IronPython的新手。谢谢你的帮助和耐心。

我在Visual Studio 2015中从http://ironpython.net/安装了IronPython 2.7。 我还安装了Python 2.7.6和anaconda。

我尝试了以下解决方案但没有用。 Installing Python Packages - IronPython

我想知道IronPython可以直接使用anaconda安装的模块吗?

我试图安装的软件包是numpy,scipy,pandas,sklearn。我在2012年看到一份文件指出,IronPython不支持sklearn。还是这样吗?

感谢。

1 个答案:

答案 0 :(得分:-1)

取决于IronPython官方网站http://ironpython.net/blog/2014/12/07/pip-in-ironpython-275.html

您可以按照以下步骤进行操作

<强>步骤1

将ironPython安装路径添加到系统路径

<强>第二步

以管理员身份运行cmd并输入以下命令

//global variables
var rooms = [],
	gw = 35, //grid width
	gh = 35; //grid height

//Room
Room = function(){
	var w = Math.floor(2+Math.random()*4),
		h = Math.floor(2+Math.random()*4),
		x = Math.floor(gw/3+Math.random()*gw/3)-Math.floor(w/2),
		y = Math.floor(gh/3+Math.random()*gw/3)-Math.floor(h/2),
		grid = [];

	//create grid with -1
	grid = [];
	for(var i=0; i<gh; i++){
		grid.push([]);
		for(var j=0; j<gw; j++) grid[grid.length-1].push(-1);
		};

	//Fill grid with distances
	this.gridDistance = function(x1,y1,c){
		if(grid[y1][x1]==-1 || grid[y1][x1]>c){
			grid[y1][x1] = c;
			if(x1>0) this.gridDistance(x1-1, y1, c+1);
			if(x1<gw-1) this.gridDistance(x1+1, y1, c+1);
			if(y1>0) this.gridDistance(x1, y1-1, c+1);
			if(y1<gh-1) this.gridDistance(x1, y1+1, c+1);
			};
		return;
		};
	this.gridDistance(x,y,0);

	//block rooms and rooms border
	for(var i=0; i<rooms.length; i++){
		var x1 = rooms[i].x, y1 = rooms[i].y, w1 = rooms[i].w, h1 = rooms[i].h;
		if(x1+w1<gw) w1 = w1+1;
		if(x1>0){ x1 = x1-1; w1 = w1+1; };
		if(y1+h1<gh) h1 = h1+1;
		if(y1>0){ y1 = y1-1; h1 = h1+1; };
		for(var j=0;j<h1; j++){
			for(var k=0;k<w1; k++){
				grid[y1+j][x1+k] = -1;
				};
			};
		};

	//block spaces where room cant fit
	for(var i=0; i<grid.length; i++){
		for(var j=0;j<grid[i].length; j++){
			var tmp = false;
			if( i+h>=gh ) tmp = true;
			else if( j+w>=gw ) tmp = true;
			else {
				for(var k=i; k<i+h; k++){
					for(var l=j;l<j+w; l++){
						if( grid[k][l]<0 ) tmp = true;
						};
					};
				};
			if(tmp) grid[i][j] = -1;
			};
		};

	//find shortest distance to fitable space
	var x1=0, y1=0, c=-1;
	for(var i=0; i<grid.length; i++){
		for(var j=0;j<grid[i].length; j++){
			if(grid[i][j]>=0 && (c==-1 || grid[i][j]<c) ){
				c = grid[i][j];
				x1= j;
				y1 = i;
				};
			};
		};
	
	this.gridDistance = undefined;

	this.x = x1; this.y = y1;
	this.w = w; this.h = h;
	};

//Setup
for(var i=0; i<25; i++){
	var room = new Room();
	rooms.push(room);
	};

$('body').append('ok');

//Draw in canvas
var ctx = $("#cnvs")[0].getContext("2d"),
	sz = 20;
ctx.beginPath();
ctx.lineWidth = '1';
ctx.strokeStyle = '#666';
for(var i=0; i<gh; i++){ ctx.moveTo(0,i*sz); ctx.lineTo(gw*sz,i*sz); };
for(var i=0; i<gw; i++){ ctx.moveTo(i*sz,0); ctx.lineTo(i*sz,gh*sz); };
ctx.stroke();

ctx.beginPath();
ctx.lineWidth = "2";
ctx.strokeStyle = '#fff';
for(var i=0; i<rooms.length; i++){ ctx.rect(rooms[i].x*sz,rooms[i].y*sz,rooms[i].w*sz,rooms[i].h*sz); ctx.stroke(); };

现在您可以安装所有内容,只需按照以下命令添加任何包

即可
ipy -X:Frames -m ensurepip