如何向Anaconda添加模块 [英] how to add a module to Anaconda

查看:793
本文介绍了如何向Anaconda添加模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这就是我执行" python -V "

Python 2.7.11 :: Anaconda 2.4.0(64位) 我通常使用终端玩IDLE.但是现在我还安装了IDLE shell.

Python 2.7.11 :: Anaconda 2.4.0 (64-bit) I usually use my terminal to play with IDLE.But now i have also installed IDLE shell.

我都尝试了 import sys; sys.path .它们抛出了不同的路径. 我的航站楼返回了其中带有蟒蛇的路径.

I tried import sys;sys.path on both.They throw different paths. My Terminal returned the path with anaconda in it.

我尝试按照以下步骤安装模块.

I tried to install a module following these steps.

  1. python setup.py sdist

  1. python setup.py sdist

sudo python setup.py install

sudo python setup.py install

然后我打开IDLE(shell).我能够导入并使用我的模块.

Then i opened IDLE(shell).I was able to import and also use my module.

我想在Anaconda中做同样的事情..我尝试使用conda install filename.py.它不起作用. 请帮忙.

I wanna do the same in Anaconda..I tried using conda install filename.py.It doesn't work. Please help.

推荐答案

有几种方法可以向Anaconda添加模块.

There are several ways to add a module to Anaconda.

  • conda install <package>

pip install <package>

要制作供他人使用的软件包,您需要将其放置在人们可以像Github一样访问它的地方. 您将需要制作一个配置文件(需要yaml文件操作),您可以在此处阅读如何制作/分发软件包的信息. http://conda.pydata.org/docs/build_tutorials/pkgs.html

To make a package for others to use you will need to put it up where people can access it like Github. You will have to make a config file (takes yaml file manipulation) you can read up on how to make/distribute packages here. http://conda.pydata.org/docs/build_tutorials/pkgs.html

现在回答您的问题:使用文件和使用模块/软件包之间是有区别的.可以使用import filename将文件导入另一个python程序,其中filename.py是您要使用的文件的名称.使该模块成为您想看看这个问题的答案. 如何编写Python模块?

Now to answer your question: There is a difference between using a file and using a module/package. A file can just be imported in another python program using import filename where filename.py is the name of the file you want to use. to make that a module you want to take a look at the answer to this question. How to write a Python module?

这篇关于如何向Anaconda添加模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆