1

I was trying to convert a code from python 2 to python 3 but one module has a .pyx extension. I tried to import the below code to import a .pyx extension file in jupyter notebook but its throwing an error. Tried the same in spyder too but then it shows no commands supplied. Is there any easy method to import the file as a module in my python code?

from distutils.core import setup, Extension
from Cython.Build import cythonize
import numpy

package = Extension('deepnovo_cython_modules', ['deepnovo_cython_modules.pyx'], include_dirs=[numpy.get_include()])
setup(ext_modules=cythonize([package])) 

the error thrown is

Traceback (most recent call last):
  File "C:\Users\minto\anaconda3\envs\tf_env\lib\distutils\fancy_getopt.py", line 233, in getopt
    opts, args = getopt.getopt(args, short_opts, self.long_opts)
  File "C:\Users\minto\anaconda3\envs\tf_env\lib\getopt.py", line 95, in getopt
    opts, args = do_shorts(opts, args[0][1:], shortopts, args[1:])
  File "C:\Users\minto\anaconda3\envs\tf_env\lib\getopt.py", line 195, in do_shorts
    if short_has_arg(opt, shortopts):
  File "C:\Users\minto\anaconda3\envs\tf_env\lib\getopt.py", line 211, in short_has_arg
    raise GetoptError(_('option -%s not recognized') % opt, opt)
getopt.GetoptError: option -f not recognized

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\minto\anaconda3\envs\tf_env\lib\distutils\core.py", line 134, in setup
    ok = dist.parse_command_line()
  File "C:\Users\minto\anaconda3\envs\tf_env\lib\distutils\dist.py", line 475, in parse_command_line
    args = parser.getopt(args=self.script_args, object=self)
  File "C:\Users\minto\anaconda3\envs\tf_env\lib\distutils\fancy_getopt.py", line 235, in getopt
    raise DistutilsArgError(msg)
distutils.errors.DistutilsArgError: option -f not recognized

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\minto\anaconda3\envs\tf_env\lib\site-packages\IPython\core\interactiveshell.py", line 3552, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "C:\Users\minto\AppData\Local\Temp\ipykernel_19296\1354990193.py", line 6, in <cell line: 6>
    setup(ext_modules=cythonize([package]))
  File "C:\Users\minto\anaconda3\envs\tf_env\lib\distutils\core.py", line 136, in setup
    raise SystemExit(gen_usage(dist.script_name) + "\nerror: %s" % msg)
SystemExit: usage: ipykernel_launcher.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: ipykernel_launcher.py --help [cmd1 cmd2 ...]
   or: ipykernel_launcher.py --help-commands
   or: ipykernel_launcher.py cmd --help

error: option -f not recognized

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\minto\anaconda3\envs\tf_env\lib\site-packages\IPython\core\ultratb.py", line 1101, in get_records
    return _fixed_getinnerframes(etb, number_of_lines_of_context, tb_offset)
  File "C:\Users\minto\anaconda3\envs\tf_env\lib\site-packages\IPython\core\ultratb.py", line 248, in wrapped
    return f(*args, **kwargs)
  File "C:\Users\minto\anaconda3\envs\tf_env\lib\site-packages\IPython\core\ultratb.py", line 281, in _fixed_getinnerframes
    records = fix_frame_records_filenames(inspect.getinnerframes(etb, context))
  File "C:\Users\minto\anaconda3\envs\tf_env\lib\inspect.py", line 1541, in getinnerframes
    frameinfo = (tb.tb_frame,) + getframeinfo(tb, context)
AttributeError: 'tuple' object has no attribute 'tb_frame'

I tried to run the same file in spyder and this error occurred

runfile('C:/Users/minto/Desktop/DeepNovo-DIA-master/deepnovo_cython_setup.py', wdir='C:/Users/minto/Desktop/DeepNovo-DIA-master')
An exception has occurred, use %tb to see the full traceback.

Traceback (most recent call last):

  File "C:\Users\minto\anaconda3\envs\tf_env\lib\distutils\core.py", line 134, in setup
    ok = dist.parse_command_line()

  File "C:\Users\minto\anaconda3\envs\tf_env\lib\distutils\dist.py", line 501, in parse_command_line
    raise DistutilsArgError("no commands supplied")

DistutilsArgError: no commands supplied


During handling of the above exception, another exception occurred:

SystemExit: usage: deepnovo_cython_setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: deepnovo_cython_setup.py --help [cmd1 cmd2 ...]
   or: deepnovo_cython_setup.py --help-commands
   or: deepnovo_cython_setup.py cmd --help

error: no commands supplied

0 Answers0