I've been using Python to treat some data that is in netcdf format... Usually I type the code within Pycharm a Python IDE, which I've configure to run the Python scripts with the system install.
To read the .nc files I use the NetCDF4 package and I've no problem when running within Pycharm. However, when I try to run the same script but from the system command line I always got the following error:
Traceback (most recent call last):
File "CheckDate.py", line 2, in <module>
import netCDF4 as n4
ImportError: /usr/local/lib/python2.7/dist-packages/netCDF4.so: undefined symbol: nc_inq_var_endian
Can anybody give me some help to fix this?
Related
I tried to run Python3 on my Windows but it gives me a AttributeError from io.py.
I have tried both the Windows Store version and Download from https://www.python.org/downloads/
When I try to run python3 or py in PowerShell 7.2.6 terminal I get
PS>python3
>Fatal Python error: init_sys_streams: can't initialize sys standard streams
Python runtime state: core initialized
Traceback (most recent call last):
File "C:\Program\Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1776.0_x64__qbz5n2kfra8p0\lib\io.py", line 87, in <module>
AttributeError: module 'abc' has no attribute 'ABCMeta'
or
PS>py
>Fatal Python error: init_sys_streams: can't initialize sys standard streams
Python runtime state: core initialized
Traceback (most recent call last):
File "C:\Users\UserName\AppData\Local\Programs\Python\Python310\lib\io.py", line 87, in <module>
AttributeError: module 'abc' has no attribute 'ABCMeta'
With troubleshooting I have tried a few things
To reinstall both from the Windows Store and the Download from https://www.python.org/downloads/, but it doesn't seem to resolve the problem.
Only run the store version or the download from the website.
I have tried to troubleshoot on the internet, but I don't see anything when it comes to running Python alone. And usually comes down to naming Python scripts which I don't want to run specificly.
I thought it could be a systen PATH problem in Windows, but that seems to be not the case as it still didnt work after I changed the path to "C:\Users\UserName\AppData\Local\Programs\Python\Python310" and "C:\Users\UserName\AppData\Local\Programs\Python\Python310\Scripts".
And the problem seems to come from the io.py which can't see the attribute ABCMeta from the module abc.
How can I solve this problem?
I've recently written some code to process some data which I need to be done every day at the same time. As a result I researched various methods and attempted to do this using the Windows Task scheduler. For the 'Start a program' field I entered the path to the python.exe file in my computer C:\Users...\Anaconda3\python.exe and in the 'add arguments' field I entered the file path of the .py file I want to be run every day "C:\Users..................\daily_python_file.py". This didn't work so I then I tried to run .py file from the command line using the same paths I entered in the fields of the task scheduler, and received the following error:
from . import _distributor_init
Traceback (most recent call last):
File "C:\Users\...\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 22, in <module>
from . import multiarray
File "C:\Users\...\Anaconda3\lib\site-packages\numpy\core\multiarray.py", line 12, in <module>
from . import overrides
File "C:\Users\...\Anaconda3\lib\site-packages\numpy\core\overrides.py", line 7, 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\...\...\...\...\...\...\daily_python_file.py", line 7, in <module>
import numpy as np
File "C:\Users\...\Anaconda3\lib\site-packages\numpy\__init__.py", line 140, in <module>
from . import core
File "C:\Users\...\Anaconda3\lib\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.8 from "C:\Users\...\Anaconda3\python.exe"
* The NumPy version is: "1.19.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.
It works fine to run the .py file when running it from the anaconda prompt command line. I also created a test python file which just contained a print function which ran no problem from the windows command line, (I'm assuming because this .py file has no dependencies (i.e. numpy, pandas etc). I'm aware that it might have something to do with where the modules are installed (which anaconda environment) but I'm not sure how to turn this into a solution. There are also a few questions similar to this online however I haven't found any concrete solutions.
For some background I am running Windows 10, and in the anaconda base environment python 3.8.5, numpy 1.19.2.
Any help on this matter will be massively appreciated.
UPDATE
I managed to solve this problem using a .bat file. I knew that once the anaconda base environment was activated then the python.exe file would run the .py file in question, so I compiled a .bat as follows:
call C:\Users\Stanley\Anaconda3\Scripts\activate base
C:\Users\...\Anaconda3\python.exe "C:\Users\...\...\...\...\...\...\daily_python_file.py"
Then used task scheduler to run this on a daily basis. The call line activates the base environment and then the python file runs no problem. This doesn't give a reason as to why it didn't work before however it does provide a good alternative.
I am trying to install the following package in my MacOS High Sierra 10.13.6:
https://github.com/Michalychforever/CLASS-PT
When i run the make file everything looks to work fine. It not only generate an executable, which i can run by terminal using the ./ command, but also a python wrapper. The problem is related only with the former.
When i try to import the library i get the following message:
import classy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/Users/thiagomergulhao/Library/Python/2.7/lib/python/site-packages/classy.so, 2): Symbol not found: _zdotu_
Referenced from: /Users/thiagomergulhao/Library/Python/2.7/lib/python/site-packages/classy.so
Expected in: flat namespace
in /Users/thiagomergulhao/Library/Python/2.7/lib/python/site-packages/classy.so
I am using the built-in python version (i.e 2.7.10). I already installed the Xcode 10.1 together with command line commands. My .bash_profile is:
export PATH="/Users/thiagomergulhao/Library/Python/2.7/bin:$PATH"
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
Does anyone have any ideia what is causing this problem?
I am creating a joint project using both Python and R in Visual Studio. I imported Tkinter from Python to create the interface and using R via rpy2 for analyzing data. I am stuck with this error code:
Fatal Python error: init_sys_streams: can't initialize sys standard streams
Traceback (most recent call last):
File "C:\Users\15309\OneDrive\Desktop\Python\Lib\io.py", line 54, in <module>
ImportError: cannot import name 'open_code' from 'io' (unknown location)
I am using Python 3.7 in Visual Studio and rpy2 is imported from Anaconda's Python 3.7. My instructor and I have not been able to figure out how to fix it. What do we need to do?
I guess your filename is io.py
Change its name to something else.
I try to run a python script (test.py) containing this line only:
from paraview.simple import *
I want to use the last version of paraview. So, I downloaded it from the official webpage and I uncompressed the corresponding archive into a folder, say /home/paraview.
If I do not anything more than running the script with
python test.py
I get the following error message:
Traceback (most recent call last):
File "test.py", line 2, in <module>
from paraview.simple import *
ModuleNotFoundError: No module named 'paraview'
So, I set my PYTHONPATH like this:
export PYTHONPATH=/home/paraview/lib/python2.7/site-packages:$PYTHONPATH
Then, I rerun my script and I get a different error message:
Error: Could not import vtkCommonComputationalGeometry
Segmentation fault
I tried to set LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=/home/paraview/lib
where vtkCommonComputationalGeometry.so is but it does not work.
Furthermore, if I try to locate vtkCommonComputationalGeometry, I find it in another location:
/usr/lib/x86_64-linux-gnu/libvtkCommonComputationalGeometry-6.2.so
I removed vtk with apt but it is still here.
Do you know how I could run my script?
Just use pvpython, that can be found in ParaView binaries.
path/to/ParaView/bin/pvpython test.py
try to install PVGeo package.
pip install PVGeo