ansys/pydpf-composites

Module not found and URL error.

Closed this issue · 15 comments

Before submitting the issue

  • I have visited the Troubleshooting section.
  • I have searched among the existing issues.
  • I am using a Python virtual environment.
  • I have a fully updated virtual environment (i.e. pip install --upgrade --upgrade-strategy eager ansys-mapdl-core)

Description of the bug

  File ~\untitled0.py:33 in <module>
    from ansys.dpf.composites.composite_model import CompositeModel

ModuleNotFoundError: No module named 'ansys.dpf.composites'

getting above error while running pyansys code

Steps To Reproduce

Steps:

  • First I did...

  • Check the code from official pyansys website & copied it on Anaconda Spyder

  • ...

And I ran the following code:

from ansys.mapdl.core import launch_mapdl
mapdl = launch_mapdl()

# Insert your code here
import ansys.dpf.core as dpf
import numpy as np

from ansys.dpf.composites.composite_model import CompositeModel
from ansys.dpf.composites.constants import Sym3x3TensorComponent
from ansys.dpf.composites.example_helper import get_continuous_fiber_example_files
from ansys.dpf.composites.layup_info.material_properties import MaterialProperty
from ansys.dpf.composites.select_indices import get_selected_indices
from ansys.dpf.composites.server_helpers import connect_to_or_start_server

Which Operating System are you using?

Windows

Which Python version are you using?

3.9

PyMAPDL Report

Show the Report!

# PASTE HERE THE OUTPUT OF `python -c "from ansys.mapdl import core as pymapdl; print(pymapdl.Report())"` here
Traceback (most recent call last):

  File ~\untitled0.py:33 in <module>
    from ansys.dpf.composites.composite_model import CompositeModel

ModuleNotFoundError: No module named 'ansys.dpf.composites'

Installed packages

Show the installed packages!

# PASTE HERE THE OUTPUT OF `python -m pip freeze` here
Traceback (most recent call last):

  File ~\untitled0.py:33 in <module>
    from ansys.dpf.composites.composite_model import CompositeModel

ModuleNotFoundError: No module named 'ansys.dpf.composites'

Logger output file

Show the logger output file.
Also, below issue is there
# PASTE HERE THE CONTENT OF THE LOGGER OUTPUT FILE.
ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'C:\\Users\\LENOVO\\anaconda3\\Lib\\site-packages\\~umpy\\core\\_multiarray_tests.cp39-win_amd64.pyd'
Consider using the `--user` option or check the permissions.

Hi @kunal-3196
Since you area asking about PyDPF Composites you should really post this issue its GitHub page: https://github.com/pyansys/pydpf-composites/issues

Have you pip installed PyDPF Composites? It does not seem so...but maybe the issue is post install.

Mike

Thanks will check on the link. Yes I've installed it, do u have the pip command incase to install latest one?

Hi @kunal-3196

pip install ansys-dpf-composites -U

Are you using an virtual environment for Python? I've made the mistake before of installing to different Python that I meant to use. Or can you double check that it exists in the Python site packages folder. Mike

Hi @kunal-3196

I would recommend you to check the following link regarding PyDPF-Composites:
https://composites.dpf.docs.pyansys.com/release/0.1/intro.html#installation

I would like also emphasise the importance of the activation of the correct virtual environment as @mikerife mentioned.

Got this exception:

Traceback (most recent call last):
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_vendor\urllib3\response.py", line 438, in _error_catcher
    yield
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_vendor\urllib3\response.py", line 519, in read
    data = self._fp.read(amt) if not fp_closed else b""
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 62, in read
    data = self.__fp.read(amt)
  File "C:\Users\LENOVO\anaconda3\lib\http\client.py", line 463, in read
    n = self.readinto(b)
  File "C:\Users\LENOVO\anaconda3\lib\http\client.py", line 507, in readinto
    n = self.fp.readinto(b)
  File "C:\Users\LENOVO\anaconda3\lib\socket.py", line 704, in readinto
    return self._sock.recv_into(b)
  File "C:\Users\LENOVO\anaconda3\lib\ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "C:\Users\LENOVO\anaconda3\lib\ssl.py", line 1099, in read
    return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_internal\cli\base_command.py", line 173, in _main
    status = self.run(options, args)
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_internal\cli\req_command.py", line 203, in wrapper
    return func(self, options, args)
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_internal\commands\install.py", line 315, in run
    requirement_set = resolver.resolve(
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 94, in resolve
    result = self._result = resolver.resolve(
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 472, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 366, in resolve
    failure_causes = self._attempt_to_pin_criterion(name)
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 212, in _attempt_to_pin_criterion
    criteria = self._get_updated_criteria(candidate)
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 203, in _get_updated_criteria
    self._add_to_criteria(criteria, requirement, parent=candidate)
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 172, in _add_to_criteria
    if not criterion.candidates:
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_vendor\resolvelib\structs.py", line 151, in __bool__
    return bool(self._sequence)
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 140, in __bool__
    return any(self)
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 128, in <genexpr>
    return (c for c in iterator if id(c) not in self._incompatible_ids)
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 32, in _iter_built
    candidate = func()
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 204, in _make_candidate_from_link
    self._link_candidate_cache[link] = LinkCandidate(
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 295, in __init__
    super().__init__(
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 156, in __init__
    self.dist = self._prepare()
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 227, in _prepare
    dist = self._prepare_distribution()
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 305, in _prepare_distribution
    return self._factory.preparer.prepare_linked_requirement(
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_internal\operations\prepare.py", line 508, in prepare_linked_requirement
    return self._prepare_linked_requirement(req, parallel_builds)
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_internal\operations\prepare.py", line 550, in _prepare_linked_requirement
    local_file = unpack_url(
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_internal\operations\prepare.py", line 239, in unpack_url
    file = get_http_url(
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_internal\operations\prepare.py", line 102, in get_http_url
    from_path, content_type = download(link, temp_dir.path)
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_internal\network\download.py", line 145, in __call__
    for chunk in chunks:
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_internal\cli\progress_bars.py", line 144, in iter
    for x in it:
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_internal\network\utils.py", line 63, in response_chunks
    for chunk in response.raw.stream(
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_vendor\urllib3\response.py", line 576, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_vendor\urllib3\response.py", line 541, in read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
  File "C:\Users\LENOVO\anaconda3\lib\contextlib.py", line 137, in __exit__
    self.gen.throw(typ, value, traceback)
  File "C:\Users\LENOVO\anaconda3\lib\site-packages\pip\_vendor\urllib3\response.py", line 443, in _error_catcher
    raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.

That looks like an error connecting to internet. Do you allow Python to connect to internet?

I'm transferring this issue to dpf-composite repo.

@kunal-3196 the last error you posted definitely looks like a networking problem connecting to the Python package index, as @germa89 noted.

This could be a temporary issue, in which case simply re-trying may work.

Otherwise, you can try

ping files.pythonhosted.org

to ensure you have basic connectivity. The output should look similar to

Pinging dualstack.r.ssl.global.fastly.net [151.101.129.63] with 32 bytes of data:
Reply from 151.101.129.63: bytes=32 time=5ms TTL=56
Reply from 151.101.129.63: bytes=32 time=5ms TTL=56
Reply from 151.101.129.63: bytes=32 time=6ms TTL=56
Reply from 151.101.129.63: bytes=32 time=5ms TTL=56

Ping statistics for 151.101.129.63:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 5ms, Maximum = 6ms, Average = 5ms

Have you been able to successfully install other packages with pip install? In principle, there's nothing special about ansys-dpf-composites in this step.

@roosre AFAICT this is an installation problem / question, not a bug.

noted thanks...seems my ansys version is creating issue it works only for 2023 R1 and above as they have mentioned

Yes, versions before 2023 R1 are not supported by PyDPF Composites.

However, this should not produce the same kind of error you were seeing. The Ansys version only comes into play when starting a DPF server, and loading the Composites plugin.

In other words,

python -m pip install ansys-dpf-composites
python -c 'import ansys.dpf.composites'

should work with any of the supported Python versions (3.7+).

Got this error post installing

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
pyansys 2023.1.3 requires ansys-dpf-core==0.6.0, but you have ansys-dpf-core 0.7.3 which is incompatible.
pyansys 2023.1.3 requires ansys-dpf-gate==0.2.1, but you have ansys-dpf-gate 0.3.1 which is incompatible.

This error occurs due to the pyansys meta-package (https://github.com/pyansys/pyansys). This is a collection of PyAnsys libraries, pinned to versions that are compatible. The meta-package is released once per Ansys release cycle.

Since pydpf-composites was released after the last release of this meta-package, it is not included. The ansys-dpf-core and ansys-dpf-gate are still pinned to versions older than what pydpf-composites needs.

For now, you can avoid this issue by uninstalling the meta-package:

pip uninstall pyansys
pip install ansys-dpf-composites

The packages that were originally included in the meta-package should not be uninstalled through this procedure.

From the next release of the pyansys meta-package, installing it will include pydpf-composites automatically.

DpfVersionNotSupported: The DPF Composites plugin requires DPF Server version 5.0 (Ansys 2023 R1) or later. Your version is currently 4.0.

Thanks @greschd but seems I will have to update the version only...i m getting error have tried after running meta package commands

Yes, that is expected since the DPF Composites plug-in doesn't support earlier versions.

On the Python side, I think the module is now working as expected. I'll close this issue, but feel free to re-open it or create a new one in case you need more help.