Error importing python library gedit external tools - python

I am trying to create a shortcut that execute on the selection this simple python code.
It just run a function from the library Biopython.
#!/Users/USERNAME/Library/Enthought/Canopy_64bit/User/bin/python
from Bio.Seq import reverse_complement
import sys
print reverse_complement(sys.stdin.read().rstrip())
But I get this error:
ImportError: No module named Bio.Seq
It does not make sense to me since if I run from the terminal
$ /Users/USERNAME/Library/Enthought/Canopy_64bit/User/bin/python
>>> from Bio.Seq import reverse_complement
The library is imported without any problem.
What do I do wrong? How do I tell gedit where to look for the library?

It's a problem with your path.
This should work:
#!/Users/USERNAME/Library/Enthought/Canopy_64bit/User/bin/python
import sys
sys.path.append('*yourpath of Bio module*')
from Bio.Seq import reverse_complement
print reverse_complement(sys.stdin.read().rstrip())

Related

No module named Linq

I wrote a python script to use in C#, but when I run my project this error occurs: "No module named Linq". what should I do? I took the import part from another part of project from TFS and it works well there, so what is going on?
import System
import clr
import sys
clr.AddReference(''System.Core'')
from System import Array
from System import DateTime
from System.Linq import Enumerable
from System import Func
Check your single vs double quotes.
But try "ImportExtensions"
clr.AddReference("System.Core")
import System
clr.ImportExtensions(System.Linq)

ModuleNotFoundError: No module named 'ebooklib'

Hi I'm using ebooklib in python and I'm getting this error
ModuleNotFoundError: No module named 'ebooklib'
I have successfully installed this library and it appears in my pip3 packages list.
I'm importing this in my python file like this
import os
import logging
import sys
import json
import traceback
from ast import literal_eval
from htmlparse import MyHTMLParser
from ebooklib import epub
I don't know what's wrong.
I had the same issue & fixed it by adding:
> export PYTHONPATH="/usr/local/lib/python3.8/site-packages:$PYTHONPATH"
to my .bash_profile file.
To see where your ebooklib is installed to
print(ebooklib.__file__)

Python error, Can't import from stdlib error

I'm getting at error when trying to import from qtgui site-package. Here's an excerp from the code that's having and error.
from gnuradio import qtgui
on of the files in sitepackage qtgui is textparser which contains the statement:
from stdlib import read_file
That's where the error is thrown.
Following the traceback the problem is that on of the files in qtgui, called textparser.py tries to import read_file from stdlib.
Here is the traceback of the offending line.
File "/usr/lib/python2.7/site-packages/qtgui/textparser.py", line 2, in <module>
from stdlib import read_file
ImportError: No module named stdlib
The line "from stdlib import read_file" looks correct except i cant find any information about a package called stdlib for python. However stdlib sounds like the c library. I'm new to Python, is that the proper way to import a c library?
So am I missing a python package or module, or a c library?
By the way I'm using python2.7, and Centos 7. I can't use Python 3 because I'm using GNUradio which i don't think supports Python 3.
Thanks in advance.
there is no such library in stdlib in python there is a library called stdlib_list what you gonna supposed to do in your code put a code sample

Jython ImportError: No module named * (only on Windows Server 2012)

I have a CreateDomain.py script for weblogic. And now I want to import a java class in the python script. I exported the class com.swisslog.python.util.FileNameUtil to a jar and added it to the class path before calling the python script.
Here's the start of the script:
from wlstModule import *
from java.io import FileInputStream
from java.util import Properties
import jarray.array
import os
import shutil
import traceback
import sys
import getopt
from com.swisslog.python.util import FileNameUtil
I start the script from a bat file:
set CLASSPATH=%CLASSPATH%;wm6-python-util.jar
%MW_HOME%\wlserver\common\bin\wlst.cmd common\CreateDomain.py %1 %2 %3 %4
This works on Windows 7. But on Windows Server 2012 I get following error:
ImportError: no module named swisslog
Also using the full path doesn't work (jython ImportError: No module named)
Any help would be appreciated.
I found a stupid workaround. I added a main method which calls the real methods and prints the result with system.out.print. Then I can start the jar from the python script without an import:
result = os.popen(['java', '-jar', 'python-util.jar', 'arg').read()

How do i convert a python3.4 script(that has installed modules) into a windows executable using py2exe?

I have a python script that i have to import all these modules, which some of them require downloading:
import datetime
from dateutil import parser
from tkinter import filedialog
import tkinter
import mailbox
import pprint
import json
import urllib.request
from tkinter import *
Is there a way, using py2exe, i can convert the script into a windows executable. If so, how?
To simplify the procedure, you will want to have all your modules already downloaded. This can be accomplished with a simple "pip install " from command prompt. Then it is as simple as writing and running a setup.py file - detailed directions for how to do this can be found here.

Categories

Resources