I can't install gekko package via R reticulate. My R version is 3.4.4 and my Python version is 3.8.8 and I use Gekko in Python without problems. So I tried to install on R in these two ways I know:
py_install("gekko")
reticulate::conda_install("my_conda_environment", "gekko")
However in both cases I receive the same error bellow.
PackagesNotFoundError: The following packages are not available from current channels:
gekko
Current channels:
https://conda.anaconda.org/root/win-64
https://conda.anaconda.org/root/noarch
https://repo.anaconda.com/pkgs/main/win-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/win-64
https://repo.anaconda.com/pkgs/r/noarch
https://repo.anaconda.com/pkgs/msys2/win-64
https://repo.anaconda.com/pkgs/msys2/noarch
I didn't find other alternatives in the Anaconda documentation. How can I fix this?
Edit: I solved my problem based on the references in John Hedengren's answer and reticulate docs. For that, I needed to create a new environment to specify the Python version and packages using the following code in R:
reticulate::py_install(
packages = c(
"numpy",
"pandas", # Or another packages that you need
"gekko"
),
envname = "r-gekko",
method = "conda", # On Windows, the 'conda' method is always used
python_version = "3.8.8",
pip = TRUE # It's mandatory to install gekko
)
Gekko is available from pypi.org with pip install gekko and is not available with the conda package manager with conda install gekko. Here is more information on how to install Python packages with pip. You likely already know this because you are using gekko in Python but I've included it here for some background in case others need it.
Two potential problems are:
There are multiple Python versions installed and gekko is not installed for the version that is used with R.
Reticulate is not using PyPi repositories to install gekko. Here is additional information on managing the source (either Conda or PyPi) to retrieve the packages.
I'm not familiar with R but there are others that have similar questions such as:
Error when installing package from PyPi in R using reticulate and Anaconda3
reticulate conda_install fails to install package from PyPI
Error while installing Python module in R via reticulate
How to install packages in conda that are not available in anaconda
A more general answer for help in similar cases:
Install gekko and other packages in a new environment in R.
reticulate::py_install(
packages = c(
"gekko",
"other_package==x.x.x", # It's possible to specify the package version
...
),
envname = "new_env",
method = "conda", # For Windows
python_version = "3.x.x",
pip = TRUE
)
Call reticulate package using the new environment.
Sys.setenv(RETICULATE_PYTHON = "/Users/user_name/anaconda#/envs/new_env/python.exe")
library(reticulate)
Run your Python script with gekko in R.
source_python("path/script.py")
Related
I have the same problem as this post:
Declaring a var usable by another function using a import in a secondary script, but the answer does not work on my side.
For context: basemap and basemap-data-hires are installed, yet when using resolution = 'f' it triggers the following error:
OSError: Unable to open boundary dataset file. Only the 'crude' and 'low',
resolution datasets are installed by default.
If you are requesting an, 'intermediate', 'high' or 'full'
resolution dataset, you may need to download and install those
files separately with
conda install -c conda-forge basemap-data-hires.
Here is the conda list output:
C:\Users\AlxndrLhr>conda list
# packages in environment at C:\Users\AlxndrLhr\Anaconda3\envs\map:
#
# Name Version Build Channel
basemap 1.2.2 py39h689385a_5 conda-forge
basemap-data 1.3.2 pyhd8ed1ab_0 conda-forge
basemap-data-hires 1.3.2 pyhd8ed1ab_0 conda-forge
As you can see, basemap-data-hires is present. I tried installing it in the base environment of conda, didn't work either.
Before basemap 1.3.0, the library was packaged in conda-forge by splitting the heavy data files into a separate basemap-data-hires conda package (and whose files were installed in the share folder).
Since basemap 1.3.0, a complete reorganisation of the basemap package has been done upstream by splitting the library into basemap, basemap-data and basemap-data-hires. These three packages are Python packages and get installed in the corresponding Python site-packages folder. This new structuring is propagated to the conda-forge packages.
Your installation is mixing the old basemap conda package (pre-1.3.0) with the new basemap-data-hires conda package (post-1.3.0). You can solve the issue by pinning versions during installation, either the following to install the latest basemap:
conda install "basemap>=1.3.0" "basemap-data-hires>=1.3.0"
or the following to install the pre-1.3.0 version:
conda install "basemap==1.2.2" "basemap-data-hires==1.2.2"
I'm trying to load an existing azure workspace in RStudio Azure Compute Instance like it's shown in this link: https://azure.github.io/azureml-sdk-for-r/. But, after installing azuremlsdk package when I'm running this code azuremlsdk::install_azureml(). I'm getting this error :
Attempting uninstall: certifi Found existing installation: certifi2016.9.26ERROR: Cannot uninstall 'certifi'. It is a distutilsinstalled project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.Error: Error installing package(s): 'azureml-sdk==1.10.0', 'numpy', 'pandas'
By referring to this link : https://learn.microsoft.com/en-us/azure/machine-learning/how-to-troubleshoot-environments; I tried to fix this error by running conda remove certifi through terminal of that Compute Instance & Jupyter Notebook of that Compute Instance. But, no luck.
Does anyone have any experience in resolving this issue. Please help.
Azure ML has issues with Python versions and its dependency packages, make sure you are using Python package of 3.5 to 3.8 while installing these.
While installing azureml it will search for all the dependency packages and will install all of them, in this process there will be the version issues, like pandas, numpy.. with different pip versions.
From your stack trace looks like the error is happening when we install the packages like pandas numpy etc along with azureml-train-automl-client package so try to install them before hand by checking its versions which are dependent with you python versions packages.
Check the Azure ML documentation for installation of Azure ML Additional packages.
If you investigate them azureml-train-automl requires somes data science packages including pandas, numpy, and scikit-learn.
Kindly follow below commands for conda environment:
pip install azureml-train-automl
pip install --upgrade azureml-train-automl
pip install show azureml-train-automl
It seems that the Python SDK installation conflicts with itself when using Python 3.6 (the default). I was able to install the SDK for Python 3.7:
azuremlsdk::install_azureml(conda_python_version = '3.7')
I have never used R code in python before, but would like to do so in order to implement some Poisson regression models. The reason for this is efficiency (R code for poisson regression much more efficient). I have attempted to install rpy2 by entering the following into my terminal:
conda install -c r rpy2
I have also tried to use pip install with no success. When I attempt to run this in my terminal, it returns the following error in the terminal itself:
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: /
Found conflicts! Looking for incompatible packages.
This can take several minutes. Press CTRL-C to abort.
failed
UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:
Specifications:
rpy2 -> python[version='2.7.|3.5.|3.6.|>=2.7,<2.8.0a0|>=3.5,<3.6.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0|3.4.|3.3.*']
Your python: python=3.8
If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.
After using pip install, and running some code referencing rpy2 modules, I received the following errors:
import rpy2.robjects as robjects
import rpy2.robjects.packages as rpackages
from rpy2.robjects.vectors import StrVector
package_names = ('stats')
if all(rpackages.isinstalled(x) for x in package_names):
have_package = True
else:
have_package = False
if not have_package:
utils = rpackages.importr('utils')
utils.chooseCRANmirror(ind=1)
packnames_to_install = [x for x in package_names if not rpackages.isinstalled(x)]
if len(packnames_to_install) > 0:
utils.install_packages(StrVector(packnames_to_install))
OSError: cannot load library '/Users/name/opt/anaconda3/lib/R/lib/libR.dylib': dlopen(/Users/name/opt/anaconda3/lib/R/lib/libR.dylib, 2): Library not loaded: #rpath/libreadline.6.2.dylib
Referenced from: /Users/name/opt/anaconda3/lib/R/lib/libR.dylib
Reason: image not found
NameError: name 'rpackages' is not defined
Does anyone know how I can successfully use rpy2 in my python 3.8? It seems like this is a common issue with anaconda, but I have not been able to find any actionable solutions on the web. Any help you can provide is much appreciated!
rpy2 is not available in conda's defaults channel. Try:
conda install -c conda-forge rpy2
which uses the conda-forge channel instead.
EDIT: Actually, I’ve found that the best method is to:
Use the miniconda distribution.
Create a project-specific conda environment.
Activate this environment.
Install all conda packages available in the conda defaults channel.
Then
pip install rpy2
For more details: https://www.anaconda.com/blog/using-pip-in-a-conda-environment
I am trying to package some R packages from CRAN to use in a conda environment because I am using a combination of Python and R packages for a bioinformatics pipeline. Because of other dependencies, I need to keep R at version 3.3
I made a brandnew environment with the version of Python and R I want:
$ conda create -n bioinfo python=3.6.3 r=3.3.2
There is no R installed in the root environment. Then I follow the instructions for conda skeleton:
(bioinfo)$ conda skeleton cran rootSolve
(bioinfo)$ conda skeleton cran rootSolve
(bioinfo)$ conda build r-rootsolve
For some reason, this keeps coming up with an R3.4 dependency, even though according to CRAN, the rootSolve package only needs R>=2.01! Where is this coming from??
The following NEW packages will be INSTALLED:
r-base: 3.4.2-haf99962_0
Though building the package does not actually change the version of R running in my environment, the package does not load. Any ideas, please?
R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch"
> library('rootSolve')
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/usr/people/bioc1402/miniconda3/envs/bioinfo2/lib/R/library/rootSolve/libs/rootSolve.so':
/usr/people/bioc1402/miniconda3/envs/bioinfo2/lib/R/library/rootSolve/libs/rootSolve.so: undefined symbol: R_ExternalPtrAddrFn
In addition: Warning message:
package ‘rootSolve’ was built under R version 3.4.2
Error: package or namespace load failed for ‘rootSolve’
Apparently this was a bug, now fixed in conda-build 3.1.3,
https://github.com/conda/conda-build/issues/2562
Thanks conda team!
'conda build r-rootsolve --R=3.3.1' now works appropriately with the recipe generated by conda skeleton.
Anaconda keeps telling me that cx_oracle needs python 3.4.
My conda version is 4.3.17
This is after I used the cx_Oracle-5.3-11g.win-amd64-py3.5-2.exe installer. which is supposed to be used for Python 3.5.
conda install -c anaconda cx_oracle=5.2
Fetching package metadata ...............
Solving package specifications: .
UnsatisfiableError: The following specifications were found to be in conflict:
- cx_oracle 5.2* -> python 3.4*
- python 3.5*
Use "conda info <package>" to see the dependencies for each package.
I'm doing something stupid, but I'm not sure what. yet.
ideas?
hints?
The error's telling you that the cx_oracle package you're trying to install depends on Python 3.4 b/c that's the currently available build of cx_oracle on the anaconda channel.
If you search for cx_oracle on anaconda.org, you'll see a list of available builds on several other channels, and can look for one that meets your reqs (namely v5.2, Python 3.5, win64). Doesn't look like there's one that meets that exact set of reqs, but there are a few v5.21 & v5.3 builds available. If that's close enough, then installing from say, the amodig channel may get you going: conda install -c amodig cx_oracle=5.2.1