python-module

Jython - Configuring modules path into a jython script

旧巷老猫 提交于 2019-12-24 14:26:49
问题 Looks like function os.chdir() does not works for Jython, is there another way to switch of working directory in a Jython script ? (Get the following error while running my script: OSError: [Errno 0] chdir not supported in Java) Thanks in advance for any solution. EDIT: Question title updated to match the solution. Tags too. 回答1: What Grimmy asked make me think different about my original problem (thanks to you) My goal is (was) to define a path to find local jython modules. And so the

Can not import module search from google module in python

别来无恙 提交于 2019-12-24 12:56:27
问题 I installed the google module by Mario Vilas in my virtual environment in ubuntu 14.04 with python2.7 https://pypi.python.org/pypi/google I have done this before in both windows and Ubuntu and it worked fine. However, now when I do the following >>> from google import search Traceback (most recent call last): File "<input>", line 1, in <module> ImportError: cannot import name search I am using pycharm and I can view the package and its modules and I can auto insert using ctrl+space I tried

Python - Importing a global/site-packages module rather than the file of the same name in the local directory

拥有回忆 提交于 2019-12-24 09:39:08
问题 I'm using python and virtualenv/pip. I have a module installed via pip called test_utils (it's django-test-utils). Inside one of my django apps, I want to import that module. However I also have another file test_utils.py in the same directory. If I go import test_utils , then it will import this local file. Is it possible to make python use a non-local / non-relative / global import? I suppose I can just rename my test_utils.py , but I'm curious. 回答1: You can switch the search order by

How to Import Multiple Python Modules from Other Directories

家住魔仙堡 提交于 2019-12-24 06:13:27
问题 Python newbie here. Any and all help on python structure would be much appreciated! MAIN QUES: How to Import Multiple Python Modules from Other Directories I've reassembled the repository for a project so that modules for specific tasks are within individual folders according to type of task instead of just one huge folder. Because my modules were all in one folder, I used to be able to import easily in this fashion: import sys sys.path.insert(0,'/home/myname/folder_name/all_modules') Now, I

Import object declared inside __init__.py

a 夏天 提交于 2019-12-24 03:13:04
问题 I'm having trouble understanding how objects declared inside '__init__.py' are/should be imported to other files. I have a directory structure like so top/ | |_lib/ |_ __init__.py |_ one.py File contents are as follows lib/__init__.py a=object() lib/one.py from lib import a Here is the problem. If I fire a python shell from top directory, the following command runs well >>> from lib.one import a However if I change directory to top/lib and fire a similar command in a new python shell, I get

ImportError: No module named mysql.connector using Python3?

只愿长相守 提交于 2019-12-23 21:46:49
问题 trying to import python-mysql.connector on Python 3.2.3 and receiving an odd stack. I suspect bad configuration on my ubuntu 12.04 install. vfi@ubuntu:/usr/share/pyshared$ python3 Python 3.2.3 (default, Sep 25 2013, 18:22:43) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import mysql.connector Traceback (most recent call last): File "", line 1, in ImportError: No module named mysql.connector Error in sys.excepthook: Traceback (most recent

Using help and pydoc to list python modules not working

China☆狼群 提交于 2019-12-23 19:43:48
问题 I'm trying to find out what modules I have installed for python from: this thread I've tried >>> help('modules') no Python documentation found for 'modules' >>> pydoc modules File "<stdin>", line 1 pydoc modules ^ SyntaxError: invalid syntax However, this works >>> help('numpy') along with any other module I know I have installed. This does return the modules, but is there a way to fix my help documentation? from pkgutil import iter_modules for a in iter_modules(): print a Edit I installed

How can I `import *` from a module loaded with imp?

不问归期 提交于 2019-12-23 18:55:46
问题 I currently work with keras and custom activation functions. I store those models as pickle and I would like to be able to load them again. Then I run into this issue. The problem is that the Python script which contains the custom activation function is given by path. I load this script via import imp model_module = imp.load_source('model', experiment_meta['model']['script_path']) How can I "star import" ( import * ) in this case to make the loading of the trained model work? What I've tried

Installing modules for multiple python versions

落花浮王杯 提交于 2019-12-23 13:09:20
问题 I have installed python 2.6.6 and python 2.5.5 on the same machines (Ubuntu 10.0.4), since 2.6 is my default version and 2.5 I need for maintaining old stuff. But I have a problem to install modules(MySQLdb and net-snmp) to non-default 2.5v. It seems that only 2.6 is updated when 'sudo apt-get install _module_name_' is called. Is there a way to tell for which version module should be installed? Thanks in advance 回答1: You can use easy_install . To use it for particular version, you just

cx_freeze and importing modules

独自空忆成欢 提交于 2019-12-23 10:16:35
问题 I want to compile a Python 3.3 module with submodules using cx_freeze. So, my dir strucuture is: projectname/ __init__.py submodule1/ __init__.py bootstrap.py script1.py submodule11/ script2.py submodule2/ ... In the __init__.py I import from submodule1 import bootstrap and from the bootstrap import submodule1.submodule11.script2 If I run the init file, anything is good and the script with the submodule imports is executed correctly. When I compile it, I use this setup.py: from cx_Freeze