Open obaica opened 2 years ago
make sure that you have install the setuptools-scm by : pip install setuptools-scm If this problem still can't be solved, just comment the scm related lines in setup.py
I met the same error report as obaica which commented on Nov 20, 2021. But the new code doesn't have setup.py.
@ji-0226 Since you downloaded the mech2d package as a zip file and not via Git, the mech2d-master.zip file lacks the necessary metadata for versioning. To resolve this issue, you have two options:
git clone git@github.com:haidi-ustc/mech2d.git
cd mech2d
pip install .
[build-system]
requires = ["setuptools>=61" ]
build-backend = "setuptools.build_meta"
[project] version="0.3.0" name = "mech2d" requires-python = ">=3.8" keywords = ["2D materials", "mechanical properties", "DFT"] description = "mech2d: a calculator for two dimensional material mechanical properties" authors = [ {name = "Haidi Wang", email = "haidi@hfut.edu.cn"}, ] license = {file = "LICENSE"} classifiers = [ "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", ] dependencies = [ 'numpy>=1.21.2', 'pymatgen==2023.7.17', 'dpdispatcher==0.3.39', 'custodian==2021.2.8' ] readme = "README.md"
[project.urls] Homepage = "https://gitee.com/haidi-hfut/mech2d" documentation = "https://mech2d.readthedocs.io/en/latest/" repository = "https://gitee.com/haidi-hfut/mech2d"
[project.entry-points.console_scripts] m2d = "mech2d.main:main" cvasp = "mech2d.scripts.cvasp:main"
[tool.setuptools.package-data] scripts = ['mech2d/scripts/','mech2d/scripts/submit_slurm_serial.sh']
[tool.setuptools.packages.find] include = ["mech2d*"]
hi,
I have installed mech2d but after following command:m2d -h
I get this error:
Traceback (most recent call last):
File "/usr/local/bin/m2d", line 5, in <module>
from mech2d.main import main
File "/home/shahram/.local/lib/python3.10/site-packages/mech2d/main.py", line 8, in <module>
from mech2d.mechanics import init_elastic,post_elastic
File "/home/shahram/.local/lib/python3.10/site-packages/mech2d/mechanics.py", line 28, in <module>
from mech2d.analysis import Analysis
File "/home/shahram/.local/lib/python3.10/site-packages/mech2d/analysis.py", line 20, in <module>
from mech2d.plot import Plot
File "/home/shahram/.local/lib/python3.10/site-packages/mech2d/plot.py", line 228
plt=(data='result.json',fmt='jpg',dpi=100)
^^^^^^^^^^^^^^^^^^
SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?
The bug indicates that there is invalid syntax in line 228 of plot.py. However, upon inspection, I found that the source file of plot.py only contains 225 lines. I suspect that plot.py was unintentionally altered. Try reinstalling, and if that doesn't resolve the issue, consider replacing the plot.py in the error path with the one from GitHub.
@shahramyalameha
Thank you, I installed version 0.4; The error is solved, but I get the following error:
/home/shahram/.local/lib/python3.10/site-packages/matplotlib/projections/__init__.py:63: UserWarning: Unable to import Axes3D. This may be due to multiple versions of Matplotlib being installed (e.g. as a system package and as a pip package). As a result, the 3D projection is not available.
warnings.warn("Unable to import Axes3D. This may be due to multiple versions of "
/usr/lib/python3/dist-packages/requests/__init__.py:87: RequestsDependencyWarning: urllib3 (2.0.7) or chardet (4.0.0) doesn't match a supported version!
warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
usage: m2d [-h] [-v] {init,run,post} ...
Desctiption:
------------
mech2d is a convenient script that use to calculate the mechanical properties of
2D materials, including Stress-Strain Curve, elastic constants and revalant
properties. The script works based on several sub-commands with their own options.
To see the options for the sub-commands, type "m2d sub-command -h".
positional arguments:
{init,run,post}
init Generating initial data for elastic systems.
run Run the DFT calculation for deformed structures.
post Post processing for elastic calculation.
options:
-h, --help show this help message and exit
-v, --version Display version
@shahramyalameha I have tried to install the mech2d again and find no error. please try to use conda envirment to install the mech2d:
conda create -n vmech2d python=3.10
conda activate vmech2d
git clone git@github.com:haidi-ustc/mech2d.git
cd mech2d
pip install .
(base) [class@iZuf649cbnlfsswil2f8ygZ mech2d]$ python setup.py install Traceback (most recent call last): File "/home/class/software/mech2d/setup.py", line 25, in
setuptools.setup(
File "/home/class/miniconda3/lib/python3.9/site-packages/setuptools/init.py", line 153, in setup
return distutils.core.setup(**attrs)
File "/home/class/miniconda3/lib/python3.9/distutils/core.py", line 108, in setup
_setup_distribution = dist = klass(attrs)
File "/home/class/miniconda3/lib/python3.9/site-packages/setuptools/dist.py", line 432, in init
_Distribution.init(self, {
File "/home/class/miniconda3/lib/python3.9/distutils/dist.py", line 292, in init
self.finalize_options()
File "/home/class/miniconda3/lib/python3.9/site-packages/setuptools/dist.py", line 708, in finalize_options
ep(self)
File "/home/class/miniconda3/lib/python3.9/site-packages/setuptools/dist.py", line 715, in _finalize_setup_keywords
ep.load()(self, ep.name, value)
File "/home/class/miniconda3/lib/python3.9/site-packages/setuptools_scm/integration.py", line 65, in version_keyword
dist.metadata.version = _get_version(config)
File "/home/class/miniconda3/lib/python3.9/site-packages/setuptools_scm/init.py", line 177, in _get_version
parsed_version = _do_parse(config)
File "/home/class/miniconda3/lib/python3.9/site-packages/setuptools_scm/init.py", line 135, in _do_parse
raise LookupError(
LookupError: setuptools-scm was unable to detect version for '/home/class/software/mech2d'.
Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the .git folder) don't contain the necessary metadata and will not work.
For example, if you're using pip, instead of https://github.com/user/proj/archive/master.zip use git+https://github.com/user/proj.git#egg=proj
I'm having the above problem when installing according to your method (python version 3.9.5), do you know how to fix it?