Asked  7 Months ago    Answers:  4   Viewed   40 times

Python is installed in a local directory.

My directory tree looks like this:

(local directory)/site-packages/toolkit/

My code is in here:

(local directory)/site-packages/toolkit/examples/

To run the example, I write python, and in the code I have:

from toolkit.interface import interface

And I get the error:

Traceback (most recent call last):
  File "", line 28, in ?
    from toolkit.interface import interface
ImportError: No module named toolkit.interface

I have already checked sys.path and there I have the directory /site-packages. Also, I have the file in the toolkit folder to indicate to Python that this is a package. I also have a in the examples directory.

I do not know why Python cannot find the file when it is in sys.path. Any ideas? Can it be a permissions problem? Do I need some execution permission?



Based on your comments to orip's post, I guess this is what happened:

  1. You edited on windows.
  2. The windows editor added something non-printing, perhaps a carriage-return (end-of-line in Windows is CR/LF; in unix it is LF only), or perhaps a CTRL-Z (windows end-of-file).
  3. You used WinSCP to copy the file to your unix box.
  4. WinSCP thought: "This has something that's not basic text; I'll put a .bin extension to indicate binary data."
  5. The missing (now called means python doesn't understand toolkit as a package.
  6. You create in the appropriate directory and everything works... ?
Tuesday, June 1, 2021
answered 7 Months ago

You need to install it on your system. This basically means putting the zip file where Python can find it, but by far the easiest way is pip install six. This will download it a second time, though.

Like the matplotlib installation instructions mention, six is a dependency of the dateutil package. Most sane installation methods would pull in this dependency automatically; if you had done pip install python-dateutil in the first place, this missing dependency should have been satisfied behind the scenes. If you require a completely manual installation, you should give those instructions a thorough read.

Friday, August 6, 2021
answered 4 Months ago

You should not install webapp2. It is included in the SDK, and is already in the production runtime.

Have a read of Configuring libraries that are part of the appengine environment

and here is the list of included 3rd party libs.

If you use pip/easy_install for various other libs, you will find on its own that is insufficient. You will need to link or include these libs in your project, manipulate sys.path so they can be found, and make sure these libraries are deployed.

Sunday, October 3, 2021
Connor Johnson
answered 2 Months ago

Remove the file or a directory xml with a file in it from your current directory and try again. Python will search the current directory first when importing modules. A file named or a package named xml in the current directory shadows the standard library package with the same name.

As pointed out in a comment by KeshV, you also need to remove the file xml.pyc, if it exists. In Python 2 it will be in the same directory as In Python 3 it will be in the sub directory __pycache__. In General, as long as the *.py file is around, you can savely delete the corresponding *.pyc file because Python will re-create it upon import of the *.py file.

Saturday, October 30, 2021
Quang Hoang
answered 1 Month ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :