I am quite new to python and only did smaller projects so far. For a new project I would like to use FEniCS for solving PDEs. I am working with Windows 10 and already successfully installed Ubuntu (I still do not entirely understand what Ubunutu is needed for). To test solving a PDE I executed a tutorial file "ft01_poisson.py" from the website of the FEniCS project (https://fenicsproject.org/tutorial/) in the Ubuntu command window and it worked.
Afterwards, I also wanted to execute the file in spyder since I will use Spyder for my own project to solve PDEs. I did pip install fenics and when I repeat the command it says Requirement already satisfied: fenics c:\users\airwaves12\anaconda3\envs\spyder-4.1.5\lib\site-packages (2019.1.0).
But when I execute the script in spyder I always get the error ModuleNotFoundError: No module named 'fenics'. In the above-mentioned path there are only folders called fenics_dijitso-2019.1.0.dist-info, fenics_ffc-2019.1.0.post0.dist-info, fenics_fiat-2019.1.0.dist-info, fenics_ufl-2019.1.0.dist-info and fenics-2019.1.0.dist-info.
I know that the "fenics package" consists of different subpackages as "ffc", "FIAT", "ufl" or "dijitso". Those also excist in the above-mentioned file. I tried to manually copy those subpackages saved in folder called "fenics" into the path C:\Users\Airwaves12\anaconda3\envs\spyder-4.1.5\Lib\site-packages but that obviously did not work cause python did not find for example the function UnitSquareMesh().
I spend almost two days reading everything concerning this topic and tried out a lot of things but the most useful advice was from No module named 'dolfin' using Spyder which did not work for me and was originally just for anaconda. How to use FEniCS in Jupyter Notebook or Spyder? did not get an answer for spyder so far.
Does anyone know how to properly use FEniCS with spyder? I would be grateful for any advice.
Related
I know this is a problem that's been asked here before, but I have tried all the solutions I found and not solved it. It's possible I'm not understanding the solutions, but I have tried my best.
I am teaching myself Python and it is slow going, so I don't understand a lot yet. I'm using VSCode as an IDE, Python version 3.10, and Windows 10. I only have the Python extension installed for VSCode. My project files are on a flash drive, D. I replaced a couple folder names with [Default Names] in the text below.
I keep trying to debug/run some code in VSCode and the very first line
import numpy as np
gives me the error
Exception has occurred: ModuleNotFoundError - No module named 'numpy'.
But I know that's not true:
`PS D:\0-Career\Programming\PythonCoding\[ProjectFolder]> py -m pip install numpy
Requirement already satisfied: numpy in c:\users\[UserID]\appdata\local\programs\python\python310\lib\site-packages (1.23.1)`
I tried the solution of going to
environment variables > system variables > "Path" > edit > new >
c:\users\[UserID]\appdata\local\programs\python\python310\
as well as
C:\Users\[UserID]\AppData\Local\Programs\Python\Python310\Lib\site-packages\
and
C:\Users\[UserID]\AppData\Local\Programs\Python\Python310\Scripts\
and I also tried adding a user variable called Python. Nothing appears to have changed as a result of these additions.
Some history if it's helpful:
I first started by installing Python using the Microsoft Store. I used IDLE for a bit, and I used my command line to install pip and numpy. They worked for a little while. I later installed Visual Studio Code IDE. I ultimately have uninstalled the Microsoft Store version and installed the application from the Python site for Windows instead. I have also uninstalled and reinstalled it several times trying to fix my issues, and same for numpy. I also searched my C drive for "python" and burned everything from the past couple days and reinstalled and repaired it out of desperation. No luck.
I have tried to the best of my ability to uninstall everything and reinstall everything to start fresh, because numpy worked ever so briefly early on in IDLE, I think until I had installed the web download version of Python. I don't really understand environment variables, so I'm not sure what I'm doing or if I'm doing that wrong, or what needs to be restarted when I try something new, so it's possible I missed something.
Answers a 10 year old could understand would be appreciated! Or terminology I can easily research for an explanation of how to do it.
Ctrl+Shift+P open Command Palette
choose Python:Select Interpreter
Choose the right interpreter
Go to https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
Also Check 64 bit or 32 bit
Download the latest version
and open the location where you downloaded the NumPy module now press the 'SHIFT' key and press right-click on the mouse then a menu will open where you find open PowerShell. open it now PowerShell window opens in the folder now type pip install and the file name and press the TAB button and click enter. then the NumPy module will be installed.
Have Fun
Try adding the variable PYTHONPATH to your system variables and add the following paths to this variable.
C:\PATH_TO_YOUR_PYTHON_INSTALL
C:\PATH_TO_YOUR_PYTHON_INSTALL\DLLs
C:\PATH_TO_YOUR_PYTHON_INSTALL\Lib
C:\PATH_TO_YOUR_PYTHON_INSTALL\Scripts
It should look something like this.
Screenshot of Environment Variables
After you added the variable restart your VS Code and it should work.
I hope this helps.
Currently I am working on a project with Jupyter Notebook in which I need to run a matlab script (.m) which includes a function that provides me with data which i try to solve with a tensorflow model afterwards. I can set up an environment that runs the matlab code an gives me the data and I can set up an environment that does the tensorflow thing but my problem is I can`t do it in the same environment.
Here is the setup and the problems. I am using matlab.engine which I installed like described here: https://de.mathworks.com/help/matlab/matlab_external/install-the-matlab-engine-for-python.html
To run my Jupyter Notebook I first navigate to the location where my python.exe and the matlab files are lying ("C:\Users\Philipp\AppData\Local\Programs\Python\Python37-32\Scripts"). If I try to run pip install tensorflow (in Anaconda Prompt) I got a lot of different errors like the following. Conda install works but even when it is installed i can`t import it.
ImportError: No module named 'tensorflow.core' or
ERROR: Could not find a version that satisfies the requirement tensorflow or just No module named 'tensorflow'
I searched for all those problems but nothing helped me. I think this has something to do with the directory I am working in and I know it is bad but I have no idea how to change that. The error also occurs in different environments.
Have you tried running !pip install tensorflow directly in Jupyter Notebook? It's a temporary workaround, but I am having the same problems and this one helped. Remember to comment it out after installation, so you wont re-run it by accident.
I found a solution to my problem. For this I needed a Jupyter Notebook and an external .py script that I design as a Flask. I can luckily run those in different environments. I past and request the data from the server by using "get" and "post".
If someone still has another idea to do all this in one JN, I would still be happy about answers.
So long story short. I want to use requests and bs4 modules in my code. I installed them using pip install requests, pip install bs4. I double checked everything, even found installation folder and saw that the files is here, but my vs code is not detecting it and giving a error. I'm a quite new to this programming language so possibly it's a common issue. But i searched and mostly found posts about this problems on diffrent versions of linux, not windows.
Error i'm getting in vscode btw
Import "requests" could not be resolved from source
And when i'm launching the program through cmd the error is
ModuleNotFoundError: No module named 'requests'
First, you should add more information for us to know how your computer and IDE are configured. The first thing you should do is to check that VS Code is using the Python version where you have pip installed the modules. That is, clicking at the bottom-left space as in the picture below. Then checking that the modules are within that path.
Otherwise, check out virtualenv. With this tool you can create virtual environments within your project's folder and makes it easier to manage packages.
I've tried several fixes for this suggested in other threads, but no luck.
I'm new to Python. I had 3.8.5 installed and wrote a few simple scripts that worked using PyCharm and the numpy and sympy modules. Today I opened PyCharm and tried to write a simple script using numpy, but I got an error saying the numpy module did not exist. I also got this error when trying to run the older scripts. I checked in cmd with pip3, and got the result that it was already satisfied. I uninstalled Python, numpy, and PyCharm, reinstalled all and I'm having the same problem. This problem seemed to crop up on its own - I don't recall making any changes that would've caused this.
Can anyone give me other options?
One of the most common issues with Python is having multiple versions installed and losing track of which one you are using and/or which one you're installing to with pip.
In Pycharm check what interpreter your project is using. If there is more than one available chance are you installed numpy on the other one.
https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html#add-existing-interpreter
You can also install numpy direct from Pycharm, simply hover over the import statement and if it's not installed on the current interpreter it will offer you a link to click in install it.
If that doesn't help, post the exact error message and your code.
First off I would like to say that I am aware that this question has been asked before, however, none of the other posts have offered a solution that resolves the problem.
I am trying to use pandas-datareader to grab stock prices from the internet. I am using windows with python version 3.6. I first installed pandas-datareader from the console using
pip install pandas-datareader.
I then wrote a code which used the line
import pandas_datareader.data as web
It came back with the error
`ModuleNotFoundError: No module named 'pandas_datareader'
I tried to redownload pandas-datareader, just in case it didn't work the first time, but the console came back with "Requirement already satisfied" so that wasn't the problem.
From there I uninstalled pandas-datareader, and reinstalled it with
pip3 install pandas-datareader
I still got the same error message.
I was worried that it might have something to do with old versions of python installed on my computer so I deleted all files for python 2.7, but this did not help the issue. I restarted spyder and my computer and this did not help. I tried Jupiter notebook and this did not help either.
Now to take my investigation one step further, I looked in my file folders at the hidden files to see where pandas-datareader could be hiding. When I go to C:\Users\J.Shepard\Anaconda3\pkgs and C:\Users\J.Shepard\Anaconda3\pkgs I see that pandas-0.23.0-py36h830ac7b_0 is installed but I cannot find anything that looks like pandas-datareader. In fact, when I search for "pandas-datareader" in my file search, I only see 2 text files with one line of code each. I do not know what to make of this discovery but I thought it might be helpful to someone else.
I hope that I have made a good case to prove that I have genuinely tried and failed to solve this problem on my own. Based on the number of other unresolved posts related to this same question, I believe that this is a question that deserves to be asked again.
I tried conda install pandas-datareader in Anaconda Prompt. It was installed and after my computer restarted, pandas-datareader worked in spyder 3.6.