Conda and Python Modules

2024/10/11 16:28:37

Sadly, I do not understand how to install random python modules for use within iPython Notebooks with my Anaconda distribution. The issue is compounded by the fact that I need to be able to do these things without always using a live internet connection.

Most frequently I run into a problem with gcc compiling, where I can install a module with my basic Python2.7, but not with Conda or with the Anaconda/Python.exe.

  • Is Conda only able to install certain modules, as opposed to all valid python modules?

  • What is binstar?

  • What do I have to do, if anything, to a normal python module in order to make it "Conda-ready," so to speak?

  • Once I have downloaded a python module from SourceForge or GitHub or wherever, how can I ask Conda to install that module from the source files / binary on my computer (without having to connect to the internet)?

Help is greatly appreciated.

Answer

Q1: Is Conda only able to install certain modules, as opposed to all valid python modules?

If I understood your question correct, then it is along the lines "How do I get access to all the Anaconda packages"?

A: You go online (!), open your cmd.exe or shell and type:

conda update conda.

Hit y+enter when prompted. When the installer is done, you type:

conda update anaconda.

If you get an error in that process, then I would guess your $PATH$ variable needs a check. Google this problem, or cd into the anaconda folder and try again. If it still fails, then try downloading the anaconda package from here and install it again and press Y when prompted to setup Anaconda as default python.

Q2: What is binstar?

A: A package manager. I don't think you need it.

Q3: What do I have to do, if anything, to a normal python module in order to make it "Conda-ready," so to speak?

A: Nothing. You can just run it from the IPython GUI using %run MyScript.py

Here is an example: Let's write the following Python script in a file called script.py:

print("Running script.")
x = 12
print("'x' is now equal to {0:d}.".format(x))

Now, assuming we are in the directory where this file is located, we can execute it in IPython by entering the following command:

In [1]: %run script.py
Running script.
'x' is now equal to 12.
In [2]: x
Out[2]: 12

When running the script, the standard output of the console displays any print statement. At the end of execution, the x variable defined in the script is then included in the interactive namespace, which is quite convenient.

Q4: Once I have downloaded a python module from SourceForge or GitHub or wherever, how can I ask Conda to install that module from the source files / binary on my computer (without having to connect to the internet)?

A: I don't download anything from anywhere manually. If you have to you can use pip or easy_install when absolute necessary, but before you experiment with these functions, please start by checking the Anaconda docs here. There are plenty of packages, and I would be surprised if they do not cover your needs.

https://en.xdnf.cn/q/69751.html

Related Q&A

WeakValueDictionary retaining reference to object with no more strong references

>>> from weakref import WeakValueDictionary >>> class Foo(object): ... pass >>> foo = Foo() >>> db = WeakValueDictionary() >>> db[foo-id] = foo >>…

Using pretrained glove word embedding with scikit-learn

I have used keras to use pre-trained word embeddings but I am not quite sure how to do it on scikit-learn model.I need to do this in sklearn as well because I am using vecstack to ensemble both keras s…

Is there an easy way to tell how much time is spent waiting for the Python GIL?

I have a long-running Python service and Id like to know how much cumulative wall clock time has been spent by any runnable threads (i.e., threads that werent blocked for some other reason) waiting for…

Inverse filtering using Python

Given an impulse response h and output y (both one-dimensional arrays), Im trying to find a way to compute the inverse filter x such that h * x = y, where * denotes the convolution product.For example,…

Quadruple Precision Eigenvalues, Eigenvectors and Matrix Logarithms

I am attempting to diagonalize matrices in quadruple precision, and to take their logarithms. Is there a language in which I can accomplish this using built-in functions?Note, the languages/packages i…

How to use pyinstaller with pipenv / pyenv

I am trying to ship an executable from my python script which lives inside a virtual environment using pipenv which again relies on pyenv for python versioning. For that, I want to us pyinstaller. Wha…

Sending DHCP Discover using python scapy

I am new to python and learning some network programming, I wish to send an DHCP Packet through my tap interface to my DHCP server and expecting some response from it. I tried with several packet build…

cnf argument for tkinter widgets

So, Im digging through the code here and in every class (almost) I see an argument cnf={} to the constructor, but unless Ive missed it, it is not explicitly stated what cnf is / expected to contain. Ca…

python exceptions.UnicodeDecodeError: ascii codec cant decode byte 0xa7 in

I am using scrapy with python and I have this code in a python item piplinedef process_item(self, item, spider):import pdb; pdb.set_trace()ID = str(uuid.uuid5(uuid.NAMESPACE_DNS, item[link]))I got this…

Trace Bug which happends only sometimes in CI

I have a strange bug in python code which only happens sometimes in CI.We cant reproduce it.Where is the test code:response=self.admin_client.post(url, post) self.assertEqual(200, response.status_code,…