python-import

Addressing python objects

此生再无相见时 提交于 2020-01-03 16:56:28
问题 I'm trying to use ncclient for Python. If I do this it works: from ncclient import manager m = manager.connect() If I do this it fails: import ncclient m = ncclient.manager.connect() The error is AttributeError: 'module' object has no attribute 'manager' . I don't understand what the difference is. Shouldn't that be the same method either way? Why isn't it? 回答1: Importing a module (package) does not automatically import submodule. (Some modules do. For example, importing os module also import

Python: Overwrite import of numpy from Abaqus with different version of numpy

北城余情 提交于 2020-01-03 04:54:08
问题 The Abaqus that I run has a pre-installed library (numpy) which has version 1.6.2 This is the only pre-installed module which is present as an "addon" for Abaqus (other than the native Abaqus CAE libraries). I want to be able to run a python script, executed with abaqus cae nogui=makro.py , so that I can have access to scipy as well. I am doing all this in a very strict environment (no moving around of folders at installation directories) I have tried the following: import sys sys.path.insert

Python: “ImportError: DLL load failed: The specified module could not be found.” Problems when importing ffn (finance library for python)

半城伤御伤魂 提交于 2020-01-03 04:09:07
问题 Apologies if there does in fact exist a thread that has already figured this out (I've spent a few hours attentively searching multiple sites and the GitHubs for the dependencies that seem to cause the problems), however each solution seemed fairly specific to the particular library that so and so was attempting to use. I've been messing around with quantitative finance/ algorithmic trading and have been trying to import a particular library ffn , however, per the question title, I've been

What is the best way to import new python modules in intellij?

空扰寡人 提交于 2020-01-03 02:01:59
问题 To start, I've read the answer listed here, as well as tried to follow the instructions listed here, but the instructions were for an outdated or at least for a different version of Intellij, and the preexisting SO answer described the problem, but at least for me did not provide a solution. With that in mind: I'm using IntellijIdea 2017.3 on Windows. I'm trying to create a basic web scraper in Python 3 (I'm very new at this, so I apologize in advance). To accomplish this, I want to use the

Python module import - why are components only available when explicitly imported?

烂漫一生 提交于 2020-01-01 08:24:08
问题 I have recently installed scikit-image version 0.11.3. I am using python 2.7.10. When I import the entire module I cannot access the io module. import skimage img = skimage.io.imread(path_) Gives error: AttributeError: 'module' object has no attribute 'io' However the following does not error. from skimage import io img = io.imread(path_) Question: Why? 回答1: Quick answer: IO is a submodule. Submodules need to be imported from the parent module explicitly. Long answer: From section 5.4.2 of

Python module import - why are components only available when explicitly imported?

纵饮孤独 提交于 2020-01-01 08:23:27
问题 I have recently installed scikit-image version 0.11.3. I am using python 2.7.10. When I import the entire module I cannot access the io module. import skimage img = skimage.io.imread(path_) Gives error: AttributeError: 'module' object has no attribute 'io' However the following does not error. from skimage import io img = io.imread(path_) Question: Why? 回答1: Quick answer: IO is a submodule. Submodules need to be imported from the parent module explicitly. Long answer: From section 5.4.2 of

SciPy/NumPy import guideline

我与影子孤独终老i 提交于 2020-01-01 02:46:34
问题 Notice: I checked for duplicate and nothing clearly answers my question. I trust you'll let me know if I missed something! In an effort to clean up my code, I have been looking for a standard convention for importing SciPy and NumPy in my programs. I know there is no strict guideline and I can do it the way I want, but from time to time, I still find contradictory instructions. For example, I've read somewhere that NumPy is meant to only implement the array object, while SciPy is there for

How can I make the PyDev editor selectively ignore errors?

天涯浪子 提交于 2020-01-01 01:29:16
问题 I'm using PyDev under Eclipse to write some Jython code. I've got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ISubInterface The problem is that PyDev will always flag this as an error and say "Unresolved import: ISubInterface". The code works just fine, it's just that I'd rather not have these little white/red X-marks next to my code and have my Problems tab littered with these errors. Is there a way I can add

What is the reason for using a wildcard import?

[亡魂溺海] 提交于 2019-12-31 07:36:10
问题 I have just learnt about importing modules, and I am a bit confused about the wildcard import. from module_name import * I do not understand the reason of using it at all, I see people saying not to use it at all. Could someone clarify what it really means, and why would one use it? 回答1: According to [Python 3.Docs]: Modules - More on Modules ( emphasis is mine): There is even a variant to import all names that a module defines: >>> from fibo import * >>> fib(500) 0 1 1 2 3 5 8 13 21 34 55 89

Python/Django is importing the wrong module (relative when it should be absolute)

前提是你 提交于 2019-12-31 03:11:53
问题 I'm using Django 1.2 pre-alpha and Python 2.4. Yeah, I know, but I'm stuck with it. We can't upgrade at the moment and I doubt that's the answer anyway. I've got two template tag libraries, foo and bar . However, foo is also the name of a top-level package, and it happens to be the package of bar : foo-1.2.3/ foo/ conf/ settings.py templatetags/ bar.py bar-4.5/ somepackage/ templatetags/ foo.py The tag library bar.py contains a line like this: from foo.conf import settings ...and you would