Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with ulw in Python no module named examples.console #14

Closed
radiladrillingvibe opened this issue Jun 12, 2019 · 3 comments
Closed

Comments

@radiladrillingvibe
Copy link

Nub here. I downloaded 2.7 Python and Instacal and we install the MCC UL Python API for Windows (mcculw) and did the upgrade. We got the script "a_in_scan_file.py" and ran it and we keep getting "ImportError: No module named examples.console"

I asked someone familiar with MCC and he told me to add "mcculw" to line 11.

We did it and it still wont run. We only need to write to a file on the machine.

Can you help so we can start the python code?

a_in_scan_file_pyNOTE.txt

@kevin-j-morse
Copy link

Hi @radiladrillingvibe

I am not sure why this project is structured the way it is but with Python 3. I found I had to add the following two lines to a_out_scan.py in order to be able to run it.

import sys

sys.path.append(r"C:\Users\Kevin\Documents\Python")

For me, the examples folder is inside of the the Python folder.

I could then run python.exe .\examples\console\a_out_scan.py from within the Python folder.

@blakeNaccarato
Copy link

blakeNaccarato commented Dec 11, 2019

My unofficial fork puts the examples back into the main package. So instead of configuring your IDE as outlined in the readme, you can do
pip install git+https://github.com/blakeNaccarato/mcculw.git#egg=mcculw
in a Python virtualenv (or put it in your requirements.txt).

I think my "fix" is overly-complicated, compared to the suggestion by @kevin-j-morse in #14 (comment) above. At first I tried structuring the fork so that examples would install as a base-level package. Then I put examples back in mcculw, but this would require changing all imports from import examples... to import mcculw.examples.... Ultimately, just manually downloading examples.zip, extracting them, and appending the resulting directory to path as seen above is the way to go.

@john518
Copy link

john518 commented Jul 30, 2020

Since this issue is still open, may I suggest a slight variation to #14 (comment)

import os
import sys
source_dir = os.path.abspath(os.path.dirname(__file__))
home_dir = os.path.abspath(os.path.join(source_dir, os.pardir, os.pardir))
sys.path.append(home_dir)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants