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)
Related
Im trying to use vimbapython. every time I run anything that imports vimba import vimba the following error occurs:
from .c_binding import call_vimba_c, VIMBA_C_VERSION, VIMBA_IMAGE_TRANSFORM_VERSION, \
ImportError: attempted relative import with no known parent package
modules and drivers are all freshly installed.
Did anybody encountered something like that?
I have created a script where we are using multiple imports as:
import re
import time
import easygui
import can
import threading
On Converting the script to exe using pyinstaller, it fails to include the can module and hence we get error as 'CAN module not found.
Need your inputs on how to resolve this
in this example https://docs.databricks.com/user-guide/faq/cython.html
The author posted this code
import pyximport
import os
pyximport.install()
import fib
When I included the import my pyx module, it always complains
ImportError: No module named pyx_module
I looked at other sample code, like
https://www.4info.com/Blog/October-2014/Enhancing-Spark-with-IPython-Notebook-and-Cython
Spark with Cython
No one else shows this import statement. Should you be able to import the pyx module like this?
short answer is yes. you should call import pyx_module.
The reason I got confused is because I am using in a Spark code which uses zip files to pass dependencies, and the sc.addPyFiles call does not work with zip files, and import always fails.
I am using a the PYTHONSTARTUP=~/pythonstartup.py approach in order to make ipython the default python shell but I want to extend it do have some additional imports by default (like importing few common packages).
How can I do that?
#!/usr/bin/env python
import os
import sys
import re
import time
import platform
import IPython
os.environ['PYTHONSTARTUP'] = '' # Prevent running this again
IPython.start_ipython()
raise SystemExit
Problem solved by adding
IPython.start_ipython(user_ns=locals())
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()