ModuleNotFoundError: No module named 'numpy' on Fedora - python

I'm having this problem when i try to import numpy or any other modules of python on PyCharm or Visual Studio Code.
here's some things that i tried:
When i try to import direct via Python CLI the import works perfectly without any changes but when i use Visual Studio Code or Pycharm this problem happens even using their CLI, i tried the flatpak and distribution version of Pycharm and the problem continues.
I tried to change python interpreter of VSC using "commmand palette Python: Select interpreter" and the problem still happening
I installed Fedora workstation 37 on a VM only installing Pip, Numpy, VSC Flatpak via FlatHub and IntelliCode extension and the problem continues
Can someone help me?
EDIT: I find the problem, the reason why i was having this problem is because the VSC Flatpak isn't well integrated with the system therefore not able to acess SDKs of my host system.
To anyone having similar problem you can see how to solve here.

Related

vscode python extension cant install from any source

Trying to install python extension for vscode but i always encounter an error.
by the way, python 3.10.9 is installed on my pc and works correctly
i tried installing it from the vscode editor but encounterd an error
i downloaded the vsix file using 2 different PCs but that too i always lebeled as corrupt
picture is below
any ideas pleaseenter image description here
After trying for a hours, i got the solution to my case.
for me, the internet connection was slow and caused interuptions in the installation.
I realise this when i got a stronger internet connection and the extension installed properly and without any suffering.

Environment issues with running Anaconda Python in VS Code

I am trying to learn Python and debug code for the first time in VS Code (latest edition). I have anaconda running and the code I have runs fine by itself but now I need to know how to update the code and debug it for the first time.
I keep getting the following error related to NumPy:
Exception has occurred: 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.7 from "C:\Miniconda2\envs\myproject_flask\python.exe"
The NumPy version is: "1.18.5"
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: The specified module could not be found.
In the Miniconda path above the Python.exe is version 3.7.7. I tried to install NumPy like so in myproject directory:
(myproject_flask) c:\MyProject\source\MyProject.Flask>conda install numpy=1.18.5
I still get the same error when I go to F5 to debug and run to a breakpoint.
Need help with my environment.
I need to use VS Code in my Windows environment with Anaconda.
You should launch VS Code from Anaconda Navigator so that the environment is initialized.
When you have problems with importing the numpy C-extensions in Anaconda it's very likely that your virtual environment hasn't been activated. Having just Python on the path is not good enough. You also need access to the libraries. This is what the activation does.
When you are running/debugging code you should see a terminal open. You can tell from the prompt
(myproject_flask) C:\MyProject
that conda has been activated. Sometimes this just takes a bit too long for VSCode. So simply push the start button a second time.
Note that the Code Runner extension in VSCode is also known to cause this kind of problems.
However, I wonder why you are using Miniconda2 with Python3, although in general this should work.
I was getting the error even after adding all the anaconda paths, it was due to VScode running the code in the python debugger terminal which is not able to enter the conda environment.
This worked for me:
press ctrl+Shift+P > Type Terminal:Select Default profile > Select Command prompt
after this code ran in Command prompt by default, inside the environment.

Is my editor getting confused by python because I have 3.7 and 3.8?

Currently on windows 10, using VSCode to run python.
So I recently downloaded python3.8 when I was using python 3.7. Everything was working fine when I was still on python3.7. I now have multiple python directories and I think my imported libraries are throwing errors because of it.
I now have python in(these are results from searching python and right clicking -> open file location) :
C:\Python38
C:\Users\david\AppData\Roaming\Python\Python38
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Python 3.8
C:\Users\david\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.7
As for installed programs I have :
python3.8.5(64-bit)
Python launcher
Should I add all four paths to my environment...?
Frankly I don't even know anymore how to tackle this problem. I'm not even sure what the problem is I just think its a problem. If someone could link me another stackoverflow or help that would be great.
If this isn't supposed to be a problem then I guess I have some more googling to do...
Thank you
EDIT(commented below): One specific error I keep on getting is when I install keras and tensorflow, and run a program, it keeps on asking me to install tensorflow 2.2.0 even though I've already installed it. I have C:\Python38 and C:\Users\david\AppData\Roaming\Python\Python38 in my windows path and C:\Python38 as my VSCode path –

Visual Studio Code isn't working most of the modules ex. (PIL,pygame etc)

when I try to import PIL it's says "no module named PIL" error coming up. I did install PIL and try several things same thing happen with pygame earlier. please help me out.
I'm using MacOs Catalina 10.15.3
VS Code
Python 3.7.4
you need to select the right python environment, check Using Python environments in VS Code

Import Error with scikit-surprise

When I ran the example code using scikit-surprise which is a package in python, it showed that "cannot import name similarities".
My operating system is windows 10 and python version is 2.7. When I tried to ran the exactly the same code on the school computer, it succeeded. The operating system in school computer is also windows 10. So it's not the problem of operating system.
I am very confused about what happened. When I commented out the "from .. import similarities as sims", there is another import error "Import Error: No module named optimize_baselines".
When I checked what was .optimize_baselines and similarities, I found they were all .c files.
So it seems that it cannot correctly import .c files. But how to deal with that?
You see import error as those packages are not installed in your home computer. So if those are public packages then you can download it via pip or easy_install.
I solved this problem by installing python3. I installed python2 using anaconda and failed to run the system. I found that the same situation happened on my school computer that the system cannot run with python2 but succeed using python3. I am sorry that I just found I typed "scikit learn" . It should be "scikit surpirse" which is a recommendation system. I guessed the problem was because the C++ compiler. But I am not sure about that.

Categories