Error in running python file using ASE library - python

I am trying to run a python script using ASE library, I have installed ase (https://wiki.fysik.dtu.dk/ase/install.html)and run my python script using this library on my terminal. I have made a virtual env named 'MLC_env' and have already installed the ase library there.
There is a folder 'Desktop/MLC/MLC_env/lib/python3.10/site-packages/ase' which got installed over there. Now the the website (https://pypi.org/project/ase/) says Add ~/ase to your $PYTHONPATH environment variable and add ~/ase/bin to $PATH (assuming ~/ase is where your ASE folder is).
I am not able to figure out what exactly I have to do? How to add this ase folder to my pythonpath? Any suggestions will be helpful.
I tried to follow this answer Permanently add a directory to PYTHONPATH? , according to this I can try doing export PYTHONPATH="${PYTHONPATH}:/my/other/path"" where ~/ase will be the full path name of the ase folder. Shall I go ahead with this? any suggestions.
Python script
from ase import Atoms
atoms = Atoms('N2')
print(atoms.positions)
Error: While trying to run the above python script
(MLC_env) (base) anshumansinha#Anshumans-MacBook-Pro-3 Q1 % python3 struct.py
Traceback (most recent call last):
File "/Users/anshumansinha/Desktop/MLC/MLC_env/lib/python3.10/site-packages/numpy/compat/py3k.py", line 24, in <module>
import pickle5 as pickle
File "/Users/anshumansinha/.local/lib/python3.10/site-packages/pickle5/__init__.py", line 1, in <module>
from .pickle import *
File "/Users/anshumansinha/.local/lib/python3.10/site-packages/pickle5/pickle.py", line 33, in <module>
from struct import pack, unpack
File "/Users/anshumansinha/Desktop/MLC/HW1/Q1/struct.py", line 1, in <module>
from ase import Atoms
ImportError: cannot import name 'Atoms' from partially initialized module 'ase' (most likely due to a circular import) (/Users/anshumansinha/Desktop/MLC/MLC_env/lib/python3.10/site-packages/ase/__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/anshumansinha/Desktop/MLC/MLC_env/lib/python3.10/site-packages/numpy/core/__init__.py", line 23, in <module>
from . import multiarray
File "/Users/anshumansinha/Desktop/MLC/MLC_env/lib/python3.10/site-packages/numpy/core/multiarray.py", line 10, in <module>
from . import overrides
File "/Users/anshumansinha/Desktop/MLC/MLC_env/lib/python3.10/site-packages/numpy/core/overrides.py", line 8, in <module>
from numpy.compat._inspect import getargspec
File "/Users/anshumansinha/Desktop/MLC/MLC_env/lib/python3.10/site-packages/numpy/compat/__init__.py", line 12, in <module>
from . import py3k
File "/Users/anshumansinha/Desktop/MLC/MLC_env/lib/python3.10/site-packages/numpy/compat/py3k.py", line 26, in <module>
import pickle
File "/Users/anshumansinha/miniforge3/lib/python3.10/pickle.py", line 33, in <module>
from struct import pack, unpack
File "/Users/anshumansinha/Desktop/MLC/HW1/Q1/struct.py", line 1, in <module>
from ase import Atoms
ImportError: cannot import name 'Atoms' from partially initialized module 'ase' (most likely due to a circular import) (/Users/anshumansinha/Desktop/MLC/MLC_env/lib/python3.10/site-packages/ase/__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/anshumansinha/Desktop/MLC/HW1/Q1/struct.py", line 1, in <module>
from ase import Atoms
File "/Users/anshumansinha/Desktop/MLC/MLC_env/lib/python3.10/site-packages/ase/__init__.py", line 17, in <module>
from ase.atom import Atom
File "/Users/anshumansinha/Desktop/MLC/MLC_env/lib/python3.10/site-packages/ase/atom.py", line 3, in <module>
import numpy as np
File "/Users/anshumansinha/Desktop/MLC/MLC_env/lib/python3.10/site-packages/numpy/__init__.py", line 141, in <module>
from . import core
File "/Users/anshumansinha/Desktop/MLC/MLC_env/lib/python3.10/site-packages/numpy/core/__init__.py", line 49, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.10 from "/Users/anshumansinha/Desktop/MLC/MLC_env/bin/python3"
* The NumPy version is: "1.24.1"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: cannot import name 'Atoms' from partially initialized module 'ase' (most likely due to a circular import) (/Users/anshumansinha/Desktop/MLC/MLC_env/lib/python3.10/site-packages/ase/__init__.py)

Related

Not able to run Ludwig commands in terminal, and in Python also as it is saying no module installed named Ludwig

When is run "ludwig --version", it shows me the version of Ludwig installed without any errors, but when I try Ludwig train command it is showing me the error.
The error which I got after running "ludwig train --config rotten_tomatoes.yaml --dataset rotten_tomatoes.csv" is as follows:-
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/__init__.py", line 22, in <module>
from . import multiarray
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/multiarray.py", line 12, in <module>
from . import overrides
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so, 0x0002): tried: '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have (arm64), need (x86_64)))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/bin/ludwig", line 5, in <module>
from ludwig.cli import main
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/ludwig/cli.py", line 19, in <module>
import ludwig.contrib
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/ludwig/contrib.py", line 18, in <module>
from .contribs import contrib_registry
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/ludwig/contribs/__init__.py", line 40, in <module>
from .mlflow import MlflowCallback
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/ludwig/contribs/mlflow/__init__.py", line 11, in <module>
from ludwig.utils.data_utils import chunk_dict, flatten_dict, save_json, to_json_dict
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/ludwig/utils/data_utils.py", line 34, in <module>
import numpy as np
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/__init__.py", line 150, in <module>
from . import core
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/__init__.py", line 48, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.10 from "/Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10"
* The NumPy version is: "1.21.3"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so, 0x0002): tried: '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have (arm64), need (x86_64)))
And when I run "from ludwig.api import LudwigModel", it doesn't work either.
Not able to figure out how to solve the error, please help.
Are you still running into this error with the latest Ludwig release, i.e., Ludwig 0.6.4? We fixed this in Ludwig 0.6 so you shouldn't see this anymore.

numpy is installed but I got the error "DLL load failed while importing _multiarray_umath: The specified module could not be found."

I am using the Anaconda distribution with Python 3.9. Among the packages installed, I have numpy, pandas, etc. In PyCharm IDE, I have set the Project Interpreter to be the path to the python.exe installed with Anaconda: C:\Users\nguye\anaconda3\envs[Tensorflow]\pythonw.exe
P.S: I have tried every method to fix this problem on stack overflow from including more paths to uninstall and reinstall but none of those work. Please help!
C:\Users\nguye\anaconda3\envs\[Tensorflow]\pythonw.exe C:/Users/nguye/PycharmProjects/tensorEnv/main.py
Traceback (most recent call last):
File "C:\Users\nguye\anaconda3\envs\[Tensorflow]\lib\site-packages\numpy\core\__init__.py", line 23, in <module>
from . import multiarray
File "C:\Users\nguye\anaconda3\envs\[Tensorflow]\lib\site-packages\numpy\core\multiarray.py", line 10, in <module>
from . import overrides
File "C:\Users\nguye\anaconda3\envs\[Tensorflow]\lib\site-packages\numpy\core\overrides.py", line 6, in <module>
from numpy.core._multiarray_umath import (
ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\nguye\PycharmProjects\tensorEnv\main.py", line 3, in <module>
import tensorflow
File "C:\Users\nguye\anaconda3\envs\[Tensorflow]\lib\site-packages\tensorflow\__init__.py", line 37, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Users\nguye\anaconda3\envs\[Tensorflow]\lib\site-packages\tensorflow\python\__init__.py", line 37, in <module>
from tensorflow.python.eager import context
File "C:\Users\nguye\anaconda3\envs\[Tensorflow]\lib\site-packages\tensorflow\python\eager\context.py", line 26, in <module>
import numpy as np
File "C:\Users\nguye\anaconda3\envs\[Tensorflow]\lib\site-packages\numpy\__init__.py", line 144, in <module>
from . import core
File "C:\Users\nguye\anaconda3\envs\[Tensorflow]\lib\site-packages\numpy\core\__init__.py", line 49, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.9 from "C:\Users\nguye\anaconda3\envs\[Tensorflow]\pythonw.exe"
* The NumPy version is: "1.22.2"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: DLL load failed while importing _multiarray_umath: The specified module could not be found.
Process finished with exit code 1

ImportError: cannot import name 'tqdm' from 'conda._vendor.tqdm' (unknown location)

Hello I am using mac actually when I searched analytics in finder I removed some folders (I thought they are useless :) after that when I type conda update or such I am getting those errors and further more.
I am keeping exact error:
Traceback (most recent call last):
File "/Users/nunemunthalashiva/anaconda3/bin/conda", line 13, in <module>
sys.exit(main())
File "/Users/nunemunthalashiva/anaconda3/lib/python3.8/site-packages/conda/cli/main.py", line 151, in main
from ..exceptions import conda_exception_handler
File "/Users/nunemunthalashiva/anaconda3/lib/python3.8/site-packages/conda/exceptions.py", line 25, in <module>
from .common.io import dashlist, timeout
File "/Users/nunemunthalashiva/anaconda3/lib/python3.8/site-packages/conda/common/io.py", line 33, in <module>
from .._vendor.tqdm import tqdm
ImportError: cannot import name 'tqdm' from 'conda._vendor.tqdm' (unknown location)
Python comes with some libraries that are required to preform some basic operation later in python such as update or install libraries. I think you removed those python libraries that are required to update/used in other ....to remove these error you have to add/restore those libraries or reinstall python.

Can't import numpy when venv is activated with activate_this

When I activate my venv normally, things work fine.
However, when I use the activate_this.py library to activate internally to my python script, I get:
>>> this_file='win\\CYAN\Scripts\\activate_this.py'
>>> exec(open(this_file).read(), {'__file__': this_file})
>>> import numpy
Traceback (most recent call last):
File "C:\Dropbox (CEP)\venvs\win\CYAN\Lib\site-packages\numpy\core\__init__.py", line 40, in <module>
from . import multiarray
File "C:\Dropbox (CEP)\venvs\win\CYAN\Lib\site-packages\numpy\core\multiarray.py", line 12, in <module>
from . import overrides
File "C:\Dropbox (CEP)\venvs\win\CYAN\Lib\site-packages\numpy\core\overrides.py", line 6, in <module>
from numpy.core._multiarray_umath import (
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Dropbox (CEP)\venvs\win\CYAN\Lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import core
File "C:\Dropbox (CEP)\venvs\win\CYAN\Lib\site-packages\numpy\core\__init__.py", line 71, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
[LOTS of stuff about standard causes of this problem deleted ending with]
Original error was: No module named 'numpy.core._multiarray_umath'
In both cases I'm using the same python: C:\Python37\python.exe which is 64b (I ran virtualenv with -p python so the virtualenv is just a copy of that...)
ETA:
I see that there are some references from 2015 about numpy not being 64b... I assume that that's dealt with by now, because I've seen no reference to it since then... if I'm wrong, that would be good to know...
Added data: This appears to be something set up weirdly on MY computer.. when I try this on someone elses computer (set up supposedly the same way...) it works fine... Even across dropbox...
This probably has to do with the warnings I got when doing the pip install -r requirements.txt, but I'm not getting anymore so maybe there was a problem in the requirements.txt...

Error importing scipy.linalg on windows (python 3.3)

I am using python 3.3 on Windows. I downloaded scipy-0.13.2.win32-py3.3.exe from scipy-lib and installed it. However, when I tried to load scipy.linalg, interpreter displayed the following errors:
>>> import scipy.linalg
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import scipy.linalg
File "C:\Python33\lib\site-packages\scipy\linalg\__init__.py", line 157, in <module>
from .misc import *
File "C:\Python33\lib\site-packages\scipy\linalg\misc.py", line 5, in <module>
from . import blas
File "C:\Python33\lib\site-packages\scipy\linalg\blas.py", line 131, in <module>
from scipy.linalg import _fblas
ImportError: DLL load failed: The specified module could not be found.
How can I resolve this issue? Between, I checked installed library modules on my PC with the github modules at linealg-scipy and they are latest, so no issue there, I guess.
To fix this issue in both Python 2.7/3, you can install scipy from here
It will work better than the version from this deposit.

Categories