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

Install with pip #1284

Open
HoloHolo-phys opened this issue Dec 3, 2023 · 11 comments
Open

Install with pip #1284

HoloHolo-phys opened this issue Dec 3, 2023 · 11 comments

Comments

@HoloHolo-phys
Copy link

I apologize for the quite dump question, but I believe this is an issue that people stumble upon recently, and I could not find any reliable answer so far. I basically struggle to install everything correctly.

I think everything was and is quite straightforward if you use python 3.10. But at the moment it is almost retro and many want to use 3.11 at least. And install python 3.10 is not an obvious thing for not expert - it is now in security mode and the usual installer is not provided. The second thing is 'numpy migration thing' associated with deprecated 'distutils'. Simultaneously, it is not clear how important the vtk updates are. So as I view it, several important things are interconnected and if any of them is not supported by others, then nothing is working. The amount of possible errors are numerous.

However, I expect that there exist a proper set of versions for mayavi, python, vtk and numpy and everything else which would work for anyone. Can someone advise how to install it in a normal way with pip? Because the python 3.11 + pip install vtk + pip install mayavi is not working for me. And 10 other combinations which I already tried. Also, just to mention: I have installed VS build tools which are important for vtk and other things as well. So I pretty sure that my problem is about versions. Also I tried to install mayavi with: pip install https://github.com/enthought/mayavi/zipball/master. It helped but it seems like this is not a stable version of mayavi but something currently developing. It occasionally crash because of some conflicts with vtk/numpy. Like the same script can work or not completely at random.

I am also aware that possibly the conda is more supported way of installation. But unfortunately, the conda package channels are limited, I still need ~10 other packages from PyPl libraries. And if I will mix the conda and pip environments, this will be a mess and completely different problem. In any case, if you will advise using conda, I will try to dig in this direction.

Thank you very much in advance.

@timdiller
Copy link

pip install with Python 3.12 is also failing in a way that looks like a bug in the build step.
I'm on macOS 14 (Sonoma)

mayavi_test_3.12 ❯ python --version
Python 3.12.0

mayavi_test_3.12 ❯ pip --version     
pip 23.3.1 from /Users/tdiller/timdiller/venvs/mayavi_test_3.12/lib/python3.12/site-packages/pip (python 3.12)

mayavi_test_3.12 ❯ pip install mayavi
Collecting mayavi
  Using cached mayavi-4.8.1.tar.gz (20.6 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [24 lines of output]
      <string>:127: SyntaxWarning: invalid escape sequence '\.'
      <string>:128: SyntaxWarning: invalid escape sequence '\.'
      <string>:152: SyntaxWarning: invalid escape sequence '\.'
      <string>:153: SyntaxWarning: invalid escape sequence '\.'
      Traceback (most recent call last):
        File "/Users/tdiller/timdiller/venvs/mayavi_test_3.12/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Users/tdiller/timdiller/venvs/mayavi_test_3.12/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/tdiller/timdiller/venvs/mayavi_test_3.12/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/_2/1g16s0vn7t11sf8s740wm08h0000gr/T/pip-build-env-clsyqljo/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/_2/1g16s0vn7t11sf8s740wm08h0000gr/T/pip-build-env-clsyqljo/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
          self.run_setup()
        File "/private/var/folders/_2/1g16s0vn7t11sf8s740wm08h0000gr/T/pip-build-env-clsyqljo/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 480, in run_setup
          super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script)
        File "/private/var/folders/_2/1g16s0vn7t11sf8s740wm08h0000gr/T/pip-build-env-clsyqljo/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 291, in <module>
      NameError: name 'build_src' is not defined
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

@JonCrow14
Copy link

pip install isn't working for me either (for Idle Python 3.12)
windows 11 too
Screenshot 2024-01-16 224905

@HoloHolo-phys
Copy link
Author

Just to know for guys who can stumble upon this: I used Python 3.10 + pip and it worked in usual way. But I suppose many things will migrate to newer versions at some point, so it is possible that 3.10 is only a temporary solution.

@BlueSpaceship
Copy link

I tried with Python 3.9.13, 3.10.11, 3.11.7, all failed.
@HoloHolo-phys which version did you use?

@HoloHolo-phys
Copy link
Author

I tried with Python 3.9.13, 3.10.11, 3.11.7, all failed. @HoloHolo-phys which version did you use?

So here possibly all relevant packages and their versions:
Python 3.10.10

  • numpy 1.26.2
  • vtk 9.3.0
  • PyQt5 5.15.10
  • mayavi 4.8.1

Also, I dont remember if I installed mayavi with just 'pip install mayavi' or directly from github with 'pip install https://github.com/enthought/mayavi/zipball/master'.

And before VTK install, maybe it is crucial to have VS build tools being installed. Get it with "Microsoft Visual C++ Build Tools". The latest link to that is actually here: https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019

Hope it will for for you!

@wkaczan
Copy link

wkaczan commented Jan 27, 2024

I was trying to follow the instruction to install mayavi from github:
$ git clone https://github.com/enthought/mayavi.git
$ cd mayavi
$ pip install -r requirements.txt
$ pip install PyQt5 # replace this with any supported toolkit
$ python setup.py install # or develop

However there is no requirements.txt file in the mayavi folder.

@pushkarmutha
Copy link

Thanks @HoloHolo-phys. Your method worked for me. Here are the exact commands I ran

conda create --name mayavi
conda activate mayavi
#conda install -c conda-forge scipy traits jupyter ipywidgets ipyevents
conda install python=3.10
conda install numpy=1.26.2
pip install vtk==9.3.0
pip install PyQt5==5.15.10
pip install mayavi==4.8.1

@HoloHolo-phys
Copy link
Author

@woj-kaczan

NameError: name 'build_src' is not defined
Any ideas how to deal with it?

I would say that 'src' error is likely related to C++ compiler that is supposed to build VTK/mayavi libraries. VTK is C++ thing originally and python package is only a wrapper. Double check that you have something like minGW and PATH things are fine. I think it should be automatically installed with "Microsoft Visual C++ Build Tools".
I apologize if this is not helpful, I am far from these things, I am only a poor python user 😁.

@patricioastudillo
Copy link

I had the same issue with

  • Python 3.12.2
  • Ubuntu 22.04

This worked for me
pip install https://github.com/enthought/mayavi/zipball/master

@hongbo-miao
Copy link

hongbo-miao commented Dec 26, 2024

Thanks @patricioastudillo !

Here is the way to install by uv:

[project]
name = "my-project"
version = "1.0.0"
requires-python = "~=3.12.0"
dependencies = [
  "mayavi",
]

[tool.uv.sources]
mayavi = { git = "https://github.com/enthought/mayavi.git" }

Succeed on macOS (M1 chip) and Ubuntu.
Python 3.12 succeed, and Python 3.13 failed.

@aroyphillips
Copy link

Unable to install on conda with 3.13. The workaround

pip install https://github.com/enthought/mayavi/zipball/master

allowed me to install, but I could still not import properly, with the error message shown below. Is there a way to fix this issue?

File ~/miniconda3/envs/nonlinear_source_localization/lib/python3.13/site-packages/mayavi/mlab.py:15
      1 """
      2 mlab: a simple scripting interface to Mayavi2 for 3D plotting.
      3 
      4 Can be used inside Mayavi2 itself, in "ipython --gui=qt", or in any
      5 application with a compatible UI (Qt or wxPython).
      6 """
      8 # Author: Prabhu Ramachandran <[email protected]>
      9 #         Gael Varoquaux <gael dot varoquaux at normalesup dot org>
     10 # Copyright (c) 2007-2020, Enthought, Inc.
   (...)
     13 
     14 # Mayavi imports
---> 15 from mayavi.core.common import process_ui_events
     16 from mayavi.tools.camera import view, roll, yaw, pitch, move
     17 from mayavi.tools.figure import figure, clf, gcf, savefig, \
     18     draw, sync_camera, close, screenshot

File ~/miniconda3/envs/nonlinear_source_localization/lib/python3.13/site-packages/mayavi/core/common.py:21
     19     pyface = None
     20 else:
---> 21     from pyface import api as pyface
     23 # Setup a logger for this module.
     24 logger = logging.getLogger(__name__)

File ~/miniconda3/envs/nonlinear_source_localization/lib/python3.13/site-packages/pyface/api.py:141
     11 """
     12 
     13 API for the ``pyface`` package.
   (...)
    136 
    137 """
    139 # Imports which don't select the toolkit as a side-effect.
--> 141 from .application import Application
    142 from .base_toolkit import Toolkit, find_toolkit
    143 from .color import Color

File ~/miniconda3/envs/nonlinear_source_localization/lib/python3.13/site-packages/pyface/application.py:37
     34 import logging
     35 import os
---> 37 from traits.api import (
     38     Directory,
     39     Event,
     40     HasStrictTraits,
     41     Instance,
     42     ReadOnly,
     43     Str,
     44     Vetoable,
     45     VetoableEvent,
     46 )
     48 logger = logging.getLogger(__name__)
     51 class ApplicationException(Exception):

File ~/miniconda3/envs/nonlinear_source_localization/lib/python3.13/site-packages/traits/api.py:17
      1 # (C) Copyright 2005-2023 Enthought, Inc., Austin, TX
      2 # All rights reserved.
      3 #
   (...)
      8 #
      9 # Thanks for using Enthought open source!
     11 """ Pseudo-package for all of the core symbols from Traits and TraitsUI.
     12 Use this module for importing Traits names into your namespace. For example::
     13 
     14     from traits.api import HasTraits
     15 """
---> 17 from .constants import (
     18     ComparisonMode,
     19     DefaultValue,
     20     TraitKind,
     21     ValidateTrait,
     22     NO_COMPARE,
     23     OBJECT_IDENTITY_COMPARE,
     24     RICH_COMPARE,
     25 )
     27 from .trait_base import Uninitialized, Undefined, Missing, Self
     28 from .trait_converters import as_ctrait

File ~/miniconda3/envs/nonlinear_source_localization/lib/python3.13/site-packages/traits/constants.py:13
      1 # (C) Copyright 2005-2023 Enthought, Inc., Austin, TX
      2 # All rights reserved.
      3 #
   (...)
      8 #
      9 # Thanks for using Enthought open source!
     11 from enum import IntEnum
---> 13 import traits.ctraits
     16 class TraitKind(IntEnum):
     17     """ These determine the getters and setters used by the cTrait instance.
     18     """

ImportError: /home/user/miniconda3/envs/nonlinear_source_localization/lib/python3.13/site-packages/traits/ctraits.cpython-313-x86_64-linux-gnu.so: undefined symbol: Py_TRASHCAN_SAFE_BEGIN

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

9 participants