waldirio / rvtools_python

Application to be executed on Linux and collect all information from vCenter
10 stars 10 forks source link

Python 2.7 - ImportError: No module named corerv #29

Closed luizlinux closed 5 years ago

luizlinux commented 5 years ago

Getting this error when running:

# rvtools 
Traceback (most recent call last):
  File "/usr/bin/rvtools", line 5, in <module>
    pkg_resources.run_script('rvtools-python==0.0.1', 'rvtools')
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 540, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 1462, in run_script
    exec_(script_code, namespace, namespace)
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 41, in exec_
    exec("""exec code in globs, locs""")
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/rvtools_python-0.0.1-py2.7.egg/EGG-INFO/scripts/rvtools", line 7, in <module>

  File "build/bdist.linux-x86_64/egg/rvtools/rvtools.py", line 11, in <module>
ImportError: No module named corerv
#
luizlinux commented 5 years ago

Oh, I see where things are going wrong during the install:

# python setup.py install
running install
running bdist_egg
running egg_info
writing rvtools_python.egg-info/PKG-INFO
writing top-level names to rvtools_python.egg-info/top_level.txt
writing dependency_links to rvtools_python.egg-info/dependency_links.txt
reading manifest file 'rvtools_python.egg-info/SOURCES.txt'
writing manifest file 'rvtools_python.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/rvtools
copying build/lib/rvtools/__init__.py -> build/bdist.linux-x86_64/egg/rvtools
copying build/lib/rvtools/test.py -> build/bdist.linux-x86_64/egg/rvtools
copying build/lib/rvtools/corerv.py -> build/bdist.linux-x86_64/egg/rvtools
copying build/lib/rvtools/rvtools.py -> build/bdist.linux-x86_64/egg/rvtools
creating build/bdist.linux-x86_64/egg/rvtools/vinfo
copying build/lib/rvtools/vinfo/__init__.py -> build/bdist.linux-x86_64/egg/rvtools/vinfo
copying build/lib/rvtools/vinfo/vinfo.py -> build/bdist.linux-x86_64/egg/rvtools/vinfo
creating build/bdist.linux-x86_64/egg/rvtools/printrv
copying build/lib/rvtools/printrv/__init__.py -> build/bdist.linux-x86_64/egg/rvtools/printrv
copying build/lib/rvtools/printrv/csv_print.py -> build/bdist.linux-x86_64/egg/rvtools/printrv
creating build/bdist.linux-x86_64/egg/test
copying build/lib/test/__init__.py -> build/bdist.linux-x86_64/egg/test
byte-compiling build/bdist.linux-x86_64/egg/rvtools/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/rvtools/test.py to test.pyc
byte-compiling build/bdist.linux-x86_64/egg/rvtools/corerv.py to corerv.pyc
  File "build/bdist.linux-x86_64/egg/rvtools/corerv.py", line 44
    print("vcenter=<fqdn>", file=template_conf_file)
                                ^
SyntaxError: invalid syntax

byte-compiling build/bdist.linux-x86_64/egg/rvtools/rvtools.py to rvtools.pyc
byte-compiling build/bdist.linux-x86_64/egg/rvtools/vinfo/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/rvtools/vinfo/vinfo.py to vinfo.pyc
byte-compiling build/bdist.linux-x86_64/egg/rvtools/printrv/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/rvtools/printrv/csv_print.py to csv_print.pyc
byte-compiling build/bdist.linux-x86_64/egg/test/__init__.py to __init__.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
installing scripts to build/bdist.linux-x86_64/egg/EGG-INFO/scripts
running install_scripts
running build_scripts
creating build/bdist.linux-x86_64/egg/EGG-INFO/scripts
copying build/scripts-2.7/rvtools -> build/bdist.linux-x86_64/egg/EGG-INFO/scripts
changing mode of build/bdist.linux-x86_64/egg/EGG-INFO/scripts/rvtools to 755
copying rvtools_python.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying rvtools_python.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying rvtools_python.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying rvtools_python.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist/rvtools_python-0.0.1-py2.7.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing rvtools_python-0.0.1-py2.7.egg
Removing /usr/lib/python2.7/site-packages/rvtools_python-0.0.1-py2.7.egg
Copying rvtools_python-0.0.1-py2.7.egg to /usr/lib/python2.7/site-packages
rvtools-python 0.0.1 is already the active version in easy-install.pth
Installing rvtools script to /usr/bin

Installed /usr/lib/python2.7/site-packages/rvtools_python-0.0.1-py2.7.egg
Processing dependencies for rvtools-python==0.0.1
Finished processing dependencies for rvtools-python==0.0.1
#
There:
byte-compiling build/bdist.linux-x86_64/egg/rvtools/corerv.py to corerv.pyc
  File "build/bdist.linux-x86_64/egg/rvtools/corerv.py", line 44
    print("vcenter=<fqdn>", file=template_conf_file)
                                ^
SyntaxError: invalid syntax

Corerv is no getting built. :(

luizlinux commented 5 years ago

Running on Python 2.7.5, by the way.

luizlinux commented 5 years ago

Changed the print functions on corerv.py so they are more pyhton 2.7 friendly:

# diff ./rvtools/corerv.py ./rvtools/corerv.py.orig 
44,47c44,47
<       print >>template_conf_file, "vcenter=<fqdn>"
<       print >>template_conf_file, "username=<vcenter username>"
<       print >>template_conf_file, "password=<password>"
<       print >>template_conf_file, "directory=<directory>"
---
>             print("vcenter=<fqdn>", file=template_conf_file)
>             print("username=<vcenter username>", file=template_conf_file)
>             print("password=<password>", file=template_conf_file)
>             print("directory=<directory>", file=template_conf_file)
# 

Now install runs without any errors:

# python setup.py install
running install
running bdist_egg
running egg_info
writing rvtools_python.egg-info/PKG-INFO
writing top-level names to rvtools_python.egg-info/top_level.txt
writing dependency_links to rvtools_python.egg-info/dependency_links.txt
reading manifest file 'rvtools_python.egg-info/SOURCES.txt'
writing manifest file 'rvtools_python.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
copying rvtools/corerv.py -> build/lib/rvtools
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/rvtools
copying build/lib/rvtools/__init__.py -> build/bdist.linux-x86_64/egg/rvtools
copying build/lib/rvtools/test.py -> build/bdist.linux-x86_64/egg/rvtools
copying build/lib/rvtools/rvtools.py -> build/bdist.linux-x86_64/egg/rvtools
creating build/bdist.linux-x86_64/egg/rvtools/vinfo
copying build/lib/rvtools/vinfo/__init__.py -> build/bdist.linux-x86_64/egg/rvtools/vinfo
copying build/lib/rvtools/vinfo/vinfo.py -> build/bdist.linux-x86_64/egg/rvtools/vinfo
creating build/bdist.linux-x86_64/egg/rvtools/printrv
copying build/lib/rvtools/printrv/__init__.py -> build/bdist.linux-x86_64/egg/rvtools/printrv
copying build/lib/rvtools/printrv/csv_print.py -> build/bdist.linux-x86_64/egg/rvtools/printrv
copying build/lib/rvtools/corerv.py -> build/bdist.linux-x86_64/egg/rvtools
creating build/bdist.linux-x86_64/egg/test
copying build/lib/test/__init__.py -> build/bdist.linux-x86_64/egg/test
byte-compiling build/bdist.linux-x86_64/egg/rvtools/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/rvtools/test.py to test.pyc
byte-compiling build/bdist.linux-x86_64/egg/rvtools/rvtools.py to rvtools.pyc
byte-compiling build/bdist.linux-x86_64/egg/rvtools/vinfo/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/rvtools/vinfo/vinfo.py to vinfo.pyc
byte-compiling build/bdist.linux-x86_64/egg/rvtools/printrv/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/rvtools/printrv/csv_print.py to csv_print.pyc
byte-compiling build/bdist.linux-x86_64/egg/rvtools/corerv.py to corerv.pyc
byte-compiling build/bdist.linux-x86_64/egg/test/__init__.py to __init__.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
installing scripts to build/bdist.linux-x86_64/egg/EGG-INFO/scripts
running install_scripts
running build_scripts
creating build/bdist.linux-x86_64/egg/EGG-INFO/scripts
copying build/scripts-2.7/rvtools -> build/bdist.linux-x86_64/egg/EGG-INFO/scripts
changing mode of build/bdist.linux-x86_64/egg/EGG-INFO/scripts/rvtools to 755
copying rvtools_python.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying rvtools_python.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying rvtools_python.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying rvtools_python.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist/rvtools_python-0.0.1-py2.7.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing rvtools_python-0.0.1-py2.7.egg
Removing /usr/lib/python2.7/site-packages/rvtools_python-0.0.1-py2.7.egg
Copying rvtools_python-0.0.1-py2.7.egg to /usr/lib/python2.7/site-packages
rvtools-python 0.0.1 is already the active version in easy-install.pth
Installing rvtools script to /usr/bin

Installed /usr/lib/python2.7/site-packages/rvtools_python-0.0.1-py2.7.egg
Processing dependencies for rvtools-python==0.0.1
Finished processing dependencies for rvtools-python==0.0.1
# 

But still I'm getting errors regarding corerv:

# rvtools
Traceback (most recent call last):
  File "/usr/bin/rvtools", line 5, in <module>
    pkg_resources.run_script('rvtools-python==0.0.1', 'rvtools')
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 540, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 1462, in run_script
    exec_(script_code, namespace, namespace)
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 41, in exec_
    exec("""exec code in globs, locs""")
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/rvtools_python-0.0.1-py2.7.egg/EGG-INFO/scripts/rvtools", line 7, in <module>

  File "build/bdist.linux-x86_64/egg/rvtools/rvtools.py", line 11, in <module>
ImportError: No module named corerv
#
waldirio commented 5 years ago

Hello Luiz, good afternoon

Could you create a virtual environment of python 3.6 and run from there? This app was created/tested only on 3.x

Let me know the result.

Thank you. Waldirio

waldirio commented 5 years ago

Hello Luiz, good afternoon

Could you create a virtual environment of python 3.6 and run from there? This app was created/tested only on 3.x

Let me know the result.

Thank you. Waldirio

Yea, just to keep in touch Ps.: Necessary python 3.6 or greater. Improving the code to be supported by 2.7 as well, however, isn't supporting 2.x yeat.

Thanks

luizlinux commented 5 years ago

Hello Luiz, good afternoon Could you create a virtual environment of python 3.6 and run from there? This app was created/tested only on 3.x Let me know the result. Thank you. Waldirio

Yea, just to keep in touch Ps.: Necessary python 3.6 or greater. Improving the code to be supported by 2.7 as well, however, isn't supporting 2.x yeat.

Thanks

Thanks Waldirio, I'll seek to get a python 3.6 environment.