Can't change python being used when install_keras run from RStudio within Anaconda
I have several versions of Python installed on my Windows 10 box: Python 2.7, Python 3.6, plus the pythons that appear to have been installed with Anaconda. I have RStudio installed via Anaconda.
I am trying to use the keras library in my R code. I run 'install_keras()' and receive the following error:
Error: Error 1 occurred while checking for python architecture
In addition: Warning message:
running command '"C:\Python27\/python.exe" -c "import sys; import platform;
sys.stdout.write(platform.architecture()[0])"' had status 1
I have tried running install_keras using the method and conda settings:
install_keras(method="conda", conda="C:/Development/Anaconda35/Scripts")
But I still get the same error. I have also tried resetting the PATH and RETICULATE_PYTHON environmental variables, using Sys.setenv and use_python() and it doesn't seem to help.
Sys.which('PYTHON') does show the correct executable that I want to use.
Yes, my environment variables did have that Python set first in the path. But changing that didn't seem to help.
I have tried uninstalling and reinstalling keras, both the R library and the 'conda' (pip) python library. That didn't help.
I'm assuming at this point that there's some configuration or setting file with this set, but I can't seem to find it.
Suggestions?
Related
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.
I'm trying to set up a script with SQL connection, and am running into the following error:
ModuleNotFoundError: No module named 'pyodbc'
from the line:
import pyodbc
I'm using Python 3.9.2, Spyder version 4.2.3. Updated to latest Spyder version 5.0.1, no change.
Weirdly I have no trouble importing the module from the command line, it's only when I run it through Spyder that I get this issue.
Normally, from what I've read this would be a case of multiple environments, but I have yet to set up any environments so I only have one python installation.
I also have the site-packages folder properly added to path, heck I've moved the pyodbc files into their own directory and added THAT to the path.
I've copy and pasted the files into Spyder's packages directory too, but still didn't fix the issue.
The only thing I can think of is this:
which indicates that Spyder is using Python 3.7.9 as its interpreter rather than the version I actually have installed?
Any idea what the issue could be?
Thank you Ewran for your help.
When I changed the interpreter it gave me an error message to update my spyder-kernels which seems to have fixed the issue.
To summarize for others:
1). Make sure you have a path to C:\Users<User>\AppData\Local\Programs\Python\Python39\Lib\site-packages
2). Make sure you're installing the module to the correct environment
3). Make sure Spyder is using the correct interpreter, point it to the desired python.exe and update Spyder's kernels if needed.
If you are fine with the Python 3.7.9 used by Spyder, you can type
!pip install pyodbc
directly in Spyder's console to install pyodbc.
Then, the import should work.
I was getting exactly the same issue with installing using pip, but after a while of being stuck I remembered that running CMD as administrator does the trick many times -- and it did
Problem having two versions of python on my Mac and them interacting. I have the following python locations
python is /anaconda3/envs/fenicsproject/bin/python
python is /usr/bin/python
and when I try to run a script. I get the following error:
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6
I have googled some solutions and have found some posts saying I should try
env PYTHON_CONFIGURE_OPTS="--enable-framework" #or
env PYTHON_CONFIGURE_OPTS="--enable-shared"
This is they type of code I try to run
#Import packages
import dolfin as dl
I installed the env fenics by following the directions here
The google search possibly found Homebrew + Python on mac os x 10.8: Fatal Python error: PyThreadState_Get: no current thread importing mapnik however I was unable to find the library that links to a wrong version of python using otool.
I also found https://github.com/enthought/mayavi/issues/552 which suggests pinning to a different version of python.
Based on the install notes for hippy, https://hippylib.readthedocs.io/en/latest/installation.html then where they say conda create -n fenicproject ... you need to substitute the following:
conda create -n fenicsproject python==3.5.1
conda install -n fenicsproject -c conda-forge fenics==2017.2.0 \
mpi4py matplotlib scipy sympy==1.1.1 jupyter
After this, python -c 'import dolfin' no longer fails. It might also be possible to use a later version of python (I only tried 3.5.1).
What OS are you using? That will largely determine the specifics of how to go about correcting this issue, but the key here is which Python version the system path points to and what Python version your IDE is pointing to.
What you largely want to avoid is a situation where you are running Python scripts via your native system Python (2, likely).
Check which version of Python your IDE is using (from: How do I check what version of Python is running my script?):
import sys
print(sys.version)
Is the first number a 2? Did you want to use Python 2?
Next, let's check what version your system currently defaults to. If Ubuntu/Linux, use:
python -V
Is this expected? If not, you may need to change your system environmental variables to point to the correct Python version. The solution to this is OS dependent. If Windows, search "Edit Environmental Variables for Your Account" -> "Environmental Variables" -> "Path" , be sure it either points to Anaconda or the correct Python version; if Ubuntu/Linux, check your .bashrc file:
gedit ~/.bashrc
to see if the system points to the correct Python variable. If using a Mac, I formally apologize.
Hello I´m trying to run a python manage.py runserver command but getting this error message
File "C:\Users\adrie\Anaconda3\lib\sre_compile.py", line 17, in
assert _sre.MAGIC == MAGIC, "SRE module mismatch"
AssertionError: SRE module mismatch
Does anyone have idea of what´s happening here?
I had anaconda installed previously and was running fine. But then I´ve deinstalled and reinstalled anaconda, and I´m getting this error now.
Make sure you do not have any mismatch between Python interpreter version used (like 3.7) and the 're' python module (like 3.6.1).
You need reinstall IDLE or anaconda
My PYTHONHOME and PYTHONPATH environment variables were pointing to the wrong version. By fixing this import sre_compile was fixed.
Make sure your installed python version matches exactly the version anaconda uses. If not get another python version.
On Windows you can see the anaconda python version in control center -> uninstall programm -> Name of Anaconda.
Also make sure there are no older python version installed (that still might have environmental variables that point to them).
You can switch your Python version of Anaconda. There should be no need to uninstall Anaconda.
Check for available Python versions:
conda search python
Choose your preferred Python version:
conda install python=3.7.5
I am trying to run a basic demo from Fenics (2016.2.0) on Ubuntu 16.04.2, Python 2.7, Anaconda (with Spyder for the IDE). The demo is ft_01poisson.py. The error says:
RuntimeError: In instant.recompile: The module did not compile with command 'make VERBOSE=1', see '.../error/dolfin_6c..dc/compile.log'
Ok, let's take a look. Everything is fine until...
.../anaconda2/include/petscsys.h:144:6: error: #error "PETSc was configured with MPICH but now appears to be compiling using a non-MPICH mpi.h"
# error "PETSc was configured with MPICH but now appears to be compiling using a non-MPICH mpi.h"
Ok, let's see what the source says:
#elif defined(PETSC_HAVE_MPICH_NUMVERSION)
# if !defined(MPICH_NUMVERSION)
# error "PETSc was configured with MPICH but now appears to be compiling using a non-MPICH mpi.h"
I track down ~/anaconda2/include/petscconf.h:
#define PETSC_HAVE_MPICH_NUMVERSION 30200300
Now, the version of ~/anaconda2/include/mpi.h that I have in is version 2.2, but I have another version of mpi.h in a mpich-3.2.4 install which does have the correct MPICH_NUMVERSION.
I tried a simple copy and paste of the relevant files and #includes to the ~/anaconda2/include/ folder to no avail (the first error is error: ISO C++ forbids declaration of ‘type name’ with no type [-fpermissive]).
So how do I fix this? How do I get the demo to run after following the instructions to install Fenics?
So, the answer is to work within the FenicsProject Environment as suggested by
conda create -n fenicsproject -c conda-forge fenics
I would delete my own question, but I don't know how. Enjoy everyone!