I writed a py file which could run in my connda and I went implant it in slicer just litter modify.
When I test it and some erro happen just like:
RuntimeError: qSlicerScriptedLoadableModule::setPythonSource - Failed to load scripted loadable module: class off2obj was not found in file C:/Users/1/Desktop/3dp/off2obj.py…
So, firstly, can I import it with no class?
and secondly, can I run my py file in python interactor(slicer) directly just like run it in Anaconda Prompt?
If you want to run your script at every startup then you can put it into your .slicerrc.py file (Application settings / General / Application startup script).
If you want to run your script from the command-line then you can launch Slicer like this: Slicer.exe --python-script /tmp/test.py
However, the simplest and most flexible is to create a Python scripted module. You can then offer a GUI to use your script (not mandatory, but useful) and the function can be executed from Slicer’s Python console or from other modules.
In python2 there was also execfile('/tmp/code.py') but it was removed for python3. Instead I tend to use this little recipe for quick tests: eval(open('/tmp/code.py').read())