如何将模块添加到 Anaconda

时间:2023-01-23
本文介绍了如何将模块添加到 Anaconda的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

这就是我执行python -V"时得到的结果

This is what i get when i do "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.它们抛出不同的路径.我的终端返回了包含 anaconda 的路径.

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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:烧瓶调试在 Anaconda 下不起作用 下一篇:Anaconda Python:ModuleNotFoundError:没有名为“matlab"的模块

相关文章

最新文章