Packages installed with pip but python gives ModuleNotFoundError [duplicate] - python

This question already has answers here:
How do you fix "runtimeError: package fails to pass a sanity check" for numpy and pandas?
(9 answers)
Closed 1 year ago.
So I've been trying to fix this for an hour and a half (I'm basically a beginner here) and I think it's because the packages, in my case pandas folium and geojson, are not in the same place as python when I try to run my code? Just saying import pandas as pd gives me the ModuleNotFoundError.
I ran in the windows command prompt pip install pandas, the same for folium and geojson (json didn't work although the code I'm trying to run just has import json), and running which python and which pip gave the same path, but running which pandas gave a much longer return that I can't make sense of.
Additionally, running python and then import pandas as pd yields a return message that starts with some illegal values in parameter numbers and ends with The current Numpy installation fails to pass a sanity check due to a big in the windows runtime. Following the provided tinyurl in the prompt, I'm led to believe this is some kind of Windows error with numpy?
Any help would be greatly appreciated.

Try to use
pip3 install [PACKAGE_NAME]

Related

The pandas installed in my conda env is not the same version that the one used by python

I am working in a High Performance Computing and I have been using a conda env. created by the team that supports this.
Today I have been getting strange error messages such as
PandasArray object has no attribute _str_len
PandasArray object has no attribute _str_contain
I think something is going wrong.
If I read a simple csv and then I print its content I get the first error I have put above in the line that print the data frame.
I have checked the pandas version using conda list and the version is 1.2. However, if I do
python
>>> import pandas as pd
>>> print(pd._version_)
the output is 1.1.4
It is weird because when I do conda list, pandas 1.1.4 is not in that list.
Python version is 3.7.
I have also take a backup of my application to see if it is me but I have found same error I show you above. I cannot use for example .str.replace()
I have not idea what is going on but I would like to use pandas 1.2 to see if that fix the problem. How can I choose between version when running a script?

SyntaxError: future feature annotations is not defined [duplicate]

This question already has an answer here:
Can't import annotations from __future__
(1 answer)
Closed 1 year ago.
I am try to run code
sh run.sh
and it showed me the error
File "/anaconda3/envs/_galaxy_/lib/python3.6/site-packages/filelock/__init__.py", line 8
from __future__ import annotations
^
SyntaxError: future feature annotations is not defined
I saw some solutions indicated that I need to update my python version, but I am in a python verion 3.9.7.
(py39) KedeMacBook-Pro:~ ke$ python --version
Python 3.9.7
However, in the error code it showed a python veriosn of 3.6. So, I am not sure where went wrong. Why it is not using the python envrionment that I have? Please help, thank you.
Based on the error, it looks like your code is using Python 3.6 and not Python 3.9. This import is available starting from Python 3.7. Check run.sh to make sure it is referencing the right python interpreter.
I'd also recommend using a virtual env using the python version you require and running your script inside that.

Python Numpy installation sanity check error [duplicate]

This question already has answers here:
How do you fix "runtimeError: package fails to pass a sanity check" for numpy and pandas?
(9 answers)
Closed 2 years ago.
I was trying to run a block of python codes but I got this error. I installed all the necessary packages.
RuntimeError: The current Numpy installation ('D:\Program Files\Python38\lib\site-packages\numpy\init.py') fails to pass a sanity check due to a bug in the windows runtime. See this issue for more information: https://developercommunity.visualstudio.com/content/problem/1207405/fmod-after-an-update-to-windows-2004-is-causing-a.html
Does anyone know what is the problem?
This did the job:
pip install numpy==1.19.3
I can see it's a new error I also had it a couple of minutes ago when I just installed numpy and tensorflow through console.
https://developercommunity.visualstudio.com/solutions/1241964/view.html
Here the link, the link given actually worked. :)

“Error in sys$stdout$flush() : attempt to apply non-function”

I am trying to use the "reticulate" package in R to run python code in my R script. I have tried to run very simple commands just to see if it is working, and I get the following error every time.
“Error in sys$stdout$flush() : attempt to apply non-function”
I have uninstalled and installed both R and Python to the most up to date versions. I'm not sure what else to do, it seems the reticulate packages definitely works for others and only a few have had this issue with no clear answers as to why.
Please help!
library(reticulate)
py_run_string("import numpy as np")
py_run_string("my_python_array = np.array([2,4,6,8])")
print(my_python_array)
py_run_string("print(my_python_array)")
This may be the same issue as reported here: https://github.com/rstudio/reticulate/issues/584
In R, you can download the possible fix from the master branch at github:
devtools::install_github("rstudio/reticulate")

Missing numpy dependency

I'm trying to build a python script that is suppose to feed into another Matlab program. the script uses (among other things) numpy and pandas.
Here's the matlab code when I try to load the script:
path='C:\XXXXXX\Local\Continuum\anaconda3\python.exe';
pyversion(path)
algo=py.importlib.import_module('Algo_Pres');
When I try to load the script into matlab, I get an import error that seems to originate from python:
I understand the error as: pandas is missing a numpy dependency.
And yet when I turn back to python and run the script in python it works smoothly...
Where do you think the problem comes from?
PS: I checked my Library using conda list in the Prompt.
For some reason numpy is listed in the anaconda channel, whereas anything else is listed without any channel. Do you think it could be linked?

Categories