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

Cannot run example_runner.py #2

Closed
swoker opened this issue Nov 26, 2024 · 8 comments
Closed

Cannot run example_runner.py #2

swoker opened this issue Nov 26, 2024 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@swoker
Copy link

swoker commented Nov 26, 2024

Hi,

First of all, thanks for the work!
Also, I don't have ANY experience in python except running a few small scripts, so please bear with me :)

I tried to run the example_runner.py and ran into multiple problems.

1. Numpy

Traceback (most recent call last):
  File "/vagrant/cqindustry/example_runner.py", line 3, in <module>
    import example.barrier.barrier
  File "/vagrant/cqindustry/example/barrier/barrier.py", line 1, in <module>
    import cadquery as cq
  File "/home/vagrant/.local/lib/python3.10/site-packages/cadquery/__init__.py", line 22, in <module>
    from .occ_impl import exporters
  File "/home/vagrant/.local/lib/python3.10/site-packages/cadquery/occ_impl/exporters/__init__.py", line 10, in <module>
    from ...cq import Workplane
  File "/home/vagrant/.local/lib/python3.10/site-packages/cadquery/cq.py", line 62, in <module>
    from .sketch import Sketch
  File "/home/vagrant/.local/lib/python3.10/site-packages/cadquery/sketch.py", line 28, in <module>
    from .occ_impl.sketch_solver import (
  File "/home/vagrant/.local/lib/python3.10/site-packages/cadquery/occ_impl/sketch_solver.py", line 3, in <module>
    from nptyping import NDArray as Array
  File "/home/vagrant/.local/lib/python3.10/site-packages/nptyping/__init__.py", line 30, in <module>
    from nptyping.ndarray import NDArray
  File "/home/vagrant/.local/lib/python3.10/site-packages/nptyping/ndarray.py", line 32, in <module>
    from nptyping.shape_expression import (
  File "/home/vagrant/.local/lib/python3.10/site-packages/nptyping/shape_expression.py", line 35, in <module>
    from nptyping.typing_ import Literal
  File "/home/vagrant/.local/lib/python3.10/site-packages/nptyping/typing_.py", line 66, in <module>
    Bool8: TypeAlias = np.bool8
  File "/home/vagrant/.local/lib/python3.10/site-packages/numpy/__init__.py", line 414, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'bool8'. Did you mean: 'bool'?

It seems there's a hidden dependency for numpy <=1.23, but everytime I run the pip install cqindustry - numpy 2.1.3 is installed.
I have to revert it with pip install mxnet-mkl==1.6.0 numpy==1.23.1

2. cqspoolterrain missing

vagrant@ubuntu-focal:/vagrant/cqindustry$ python3 example_runner.py
Barrier Examples
Bridge Examples
Chip Tower Examples
Can Tower Examples
Traceback (most recent call last):
  File "/vagrant/cqindustry/example_runner.py", line 24, in <module>
    import example.can.can_platform
  File "/vagrant/cqindustry/example/can/can_platform.py", line 2, in <module>
    from cqindustry.can import CanPlatform
  File "/home/vagrant/.local/lib/python3.10/site-packages/cqindustry/can/__init__.py", line 3, in <module>
    from .CanTower import CanTower
  File "/home/vagrant/.local/lib/python3.10/site-packages/cqindustry/can/CanTower.py", line 3, in <module>
    from cqspoolterrain.pipe import straight
ModuleNotFoundError: No module named 'cqspoolterrain'

running this fixed the issue.

pip install git+https://github.com/medicationforall/cqspoolterrain
Successfully installed cadqueryhelper-0.2.1 cqindustry-0.1.1 cqspoolterrain-1.3.0 cqterrain-0.3.3 numpy-2.1.3
pip install ./
pip install mxnet-mkl==1.6.0 numpy==1.23.1

I had to reinstall numpy and the current package to use cqindustry-2.0.0 instead of 0.1.1 again

I guess this needs to be added in pyproject.toml?

3. error in cqspoolterrain

vagrant@ubuntu-focal:/vagrant/cqindustry$ python3 example_runner.py
Barrier Examples
Bridge Examples
Chip Tower Examples
Can Tower Examples
Traceback (most recent call last):
  File "/vagrant/cqindustry/example_runner.py", line 24, in <module>
    import example.can.can_platform
  File "/vagrant/cqindustry/example/can/can_platform.py", line 2, in <module>
    from cqindustry.can import CanPlatform
  File "/home/vagrant/.local/lib/python3.10/site-packages/cqindustry/can/__init__.py", line 3, in <module>
    from .CanTower import CanTower
  File "/home/vagrant/.local/lib/python3.10/site-packages/cqindustry/can/CanTower.py", line 3, in <module>
    from cqspoolterrain.pipe import straight
  File "/home/vagrant/.local/lib/python3.10/site-packages/cqspoolterrain/__init__.py", line 3, in <module>
    from .Cradle import Cradle
  File "/home/vagrant/.local/lib/python3.10/site-packages/cqspoolterrain/Cradle.py", line 16, in <module>
    from . import pipe
  File "/home/vagrant/.local/lib/python3.10/site-packages/cqspoolterrain/pipe/__init__.py", line 2, in <module>
    from .straight import straight
  File "/home/vagrant/.local/lib/python3.10/site-packages/cqspoolterrain/pipe/straight.py", line 17, in <module>
    from cqindustry import (
ImportError: cannot import name 'barrier_straight' from 'cqindustry' (unknown location)

it seems there's an issue inside the cqspoolterrain with the import, but I'm out of ideas how to fix this one without learning python first... :D

I think I can already create my chip tower based on the given examples, but it would be great to be able to run all examples.
Again, I have no idea about python, so please let me know if it's a user error on my side :)

Thanks!
Best
Simon

@medicationforall
Copy link
Owner

@swoker I appreciate the report! I'll poke at it when I get home.

Just out of curiosity what version of python is your linux running?
python3 --version

image

I don't do much in the way of linux testing so I appreciate the feedback.

@medicationforall medicationforall added the bug Something isn't working label Nov 26, 2024
@medicationforall medicationforall self-assigned this Nov 26, 2024
@swoker
Copy link
Author

swoker commented Nov 26, 2024

Python 3.10.12

@medicationforall
Copy link
Owner

medicationforall commented Nov 26, 2024

@swoker after poking around a bit I'm guessing the issue your hitting may be related to this issue
CadQuery/cadquery#1626

I'll check to see if there is any updates to cadquery

when All is said and done the version of cadquery I'm trying to run with is coming from one of my component libraries cadqueryhelper
https://github.com/medicationforall/cadqueryhelper/blob/main/pyproject.toml

And the version it's trying to resolve is cadquery>=2.4 which I believe is relatively up to date:
https://pypi.org/project/cadquery/#history

To get the script working you may have to mess around with the suggested workaround in the cadquery ticket
CadQuery/cadquery#1626

If you need a specific version of numpy to get the script working you can create a virtual environment I don't expect you to change your numpy version globally https://docs.python.org/3/library/venv.html

@medicationforall
Copy link
Owner

Steps to reproduce:

  1. cut a new virtual environment
  • mkvirtualenv industrybug
  1. ran pip install .
  2. ran python example_runner.py

image

@medicationforall
Copy link
Owner

Found a supporting bug
CadQuery/cadquery#1714

I'll attempt to add an old numpy version requirement to my project file and see if that helps for the time being.

@medicationforall
Copy link
Owner

medicationforall commented Nov 27, 2024

I got over the numpy version issue but I introduced a cyclical dependency between cqindustry and cqspoolterrain

cqspoolterrain install cqindustry 0.1.1 but the version were attempting run of cqindustry is 2.0.0. I need to move some code from cqspoolterrain down into cqterrain

@medicationforall
Copy link
Owner

@swoker There was a mountain of molehills that you found, which I appreciate.

Please test with the latest release of cqindustry and see if the example_runner.py works for you.
With your confirmation I'll close the ticket.

  • Moved pipes from cqspoolterrain into into cqterrain
  • Moved barrier from cqindustry into cqterrain
  • Moved walkway from cqindustry into cqterrain
  • Cleaned up circular dependencies of cqindustry and cqindustry referring to each other.
  • I ended hard coding the versions of cadquery, numpy and nlopt in cadqueryhelper medicationforall/cadqueryhelper@1.2.5...1.3.0
    I'm happy to clean up the dependency chain when a new version of cadquery releases.

Releases:
cadqueryhelper 1.3.0 - fix numpy version issue
cqterrain 2.0.0, 2.0.1, 2.0.2 - move down cyclical dependencies
cqindustry 2.0.0, 2.0.1
cqspoolterrain - next in line to get updated

@swoker
Copy link
Author

swoker commented Nov 29, 2024

Hi there,

I uninstalled everything, did a git pull, pip install ./ and ran the examples again.
It worked without any errors and created 19 STLs for Bridge Examples, Chip Tower Examples and Can Tower Examples.

Much less as before, but as you mentioned there are quite a few packages to use instead :)

Thanks for the quick fix, I will close the ticket as well

@swoker swoker closed this as completed Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants