Usage of rpy2 with a custom installation of R - python

Dear fellow programmers,
I would like to use R inside of a ipython notebook. On the system (Centos) I am working on exists an older version of R (2.15). I was able to execute R-code with this version in a ipython notebook, however, I need a newer version of R with extra packages and because I don't have administrative right for that machine, I have a local machine on which I installed the newest version of R (3.1.2). I compiled the source on my pc and flagged it in a way that it can be assessed by extensions. After that I installed rpy2 with pip and this installation went without any errors.
I also can import the rpy2 package, but when I try to load libraries, I get an error message:
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/my/homedir/Software/R-3.1.2/library/stats/libs/stats.so':
libRlapack.so: cannot open shared object file: No such file or directory
During startup - Warning message:
package \u2018stats\u2019 in options("defaultPackages") was not found
I looked it up, all libraries are present and I don't get an error when I use R without ipython.
Anyone has ideas?
Best,
Daniel

Have you tried this?
http://www.lfd.uci.edu/~gohlke/pythonlibs/#rpy2
It's very weird when you say you need admin right to update R version because R usually doesn't require admin right to be installed. Make sure you install that under your user folder, instead of somewhere in the system drive.

Related

Can't solve "No module named 'numpy'" after hours of digging

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.

Installed module is not working (windows)

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.

Python Azure Function in Visual Studio Code - DLL Error

I am trying to run a script which imports all the packages required for a code in visual studio code (there is nothing else in their at the moment apart from the import statements) all packages are installed on the environment being used.
However running just the statement
It returns the error message
I have tried uninstalling and reinstalling all packages, changing to a different environment and creating a whole new azure function.
Any help would be greatly appreciated.
It seems that there is missing a sqlite3 DLL file in your anaconda path C:\Users\954198\AppData\Local\Continuum\Anaconda3\DLLs.
Meanwhile, there is an existing SO thread Unable to import sqlite3 using Anaconda Python which got the same issue with yours, please follow the answer of most voted up to add the lack sqlite dll file to fix it.
I'm afraid that your conda environment or your python environment may be broken, sqlite3 is a default package pre-installed in Python.

0x80070643 error while installing Python 3.6

I'm actually using Python for an audio steganography project but I have some troubles.
I searched this error code on the forum, but I found things about SQL installations and not Python.
I'm trying to re-install Python 3.6.5 after an uninstall, because of a bug with pip.
I installed Python 2.7, Python 3.6.5, Python with VS 2017, before uninstall it because it wasn't working.
However, when I'm runing the installer as an administrator, hit "customize installation", tick everything excpet "balblalblabal (this requires VS 2015 or later)", and click on "install", it tells me that :
.
I realy need Python to work and I'm now stuck ...
If anybody here could help me, it would be nice !
Thanks all,
maleik.
PS : I have the log for you :*
The log link
I found this in the log file which you have attached. Try cleaning the registry with CC cleaner and give it a try. If it still doesn't work, try installing python with web installer Python Web Installed 3.6.5.
[3DA0:2968][2018-12-05T20:46:18]e000: Error 0x80070643: Failed to install MSI package.
[3DA0:2968][2018-12-05T20:46:18]e000: Error 0x80070643: Failed to execute MSI package.
[2610:03A4][2018-12-05T20:46:18]e000: Error 0x80070643: Failed to configure per-machine MSI package.
[2610:03A4][2018-12-05T20:46:18]i319: Applied execute package: core_AllUsers, result: 0x80070643, restart: None
[2610:03A4][2018-12-05T20:46:18]e000: Error 0x80070643: Failed to execute MSI package
I installed python from Microsoft store after facing this problem and it magically got installed without any error as it may have directly been installed. I don't know but try if it eorks for you too.
You need to run the installation as a local administrator.
I had the same problem installing Python version 3.9 for the first time on my Windows 10, as this same problem happens to many users trying to install Python, the best solution I accidentally, just like #MANAN AGGARWAL discovered trying to check if I already had a version of Python installed on my computer by the DOS Command Prompt, was:
Open the DOS Command Prompt (cmd) and dictate "python": if a screen shows you a version, it's clearly not the first time you've installed Python, so if you want to upgrade you should try: https: / /www.delftstack.com/en/howto/python/how-to-update-python/ But if you've never installed any version of Python, the solution lies in updating your operating system to the latest version through Windows Update, and open the command prompt and type Python, or go directly to the Microsoft Store and search for Python followed by its latest version. It works without error.
** If by chance it does not automatically install on your PC after downloading, click "install on my devices" and select your computer name.
Why can't I install Python directly from the website file? Please note that when trying to install any software/applications from outside Microsoft's trusted locations, there are high chances of user settings interfering with the installation. When coming, for example, from the Microsoft Store, a chance of success is much greater, even without having problems related to User Permission Settings.
Another important thing to point out here is that installing a lot of software from outside Microsoft's trusted platforms can cause you to change some user permissions which can have positive effects with some software and negative effects with others, even with security your own system if you don't know what you're doing.
it's simple , Try Lower Version Like 'Python 3.6' but Download web install.
install it , then install last python version.
your python will update.
I've faced same/similar problem with installing Python 3.9.12 in a clean Windows 8.1 64-bit (VirtualBoxed test environment).
I thought the issue could have been fixed in a newer version of Python, but the freshest 3.10.10 fails with same issue.
The original log isn't available any longer, but luckily it is quoted in another answer, and the following line reveals the real problem:
Applied execute package: core_AllUsers, result: 0x80070643, restart: None
My log looks the same, and if you scroll the log up, you'll discover that core_AllUsers is a UCRT MSI-installer, which is downloaded from Python site (for 3.10.10 64-bit the link may look like https://www.python.org/ftp/python/3.10.10/amd64/ucrt.msi).
If you download it manually (Python installer is smart enough to do a cleanup even if it fails, so you won't find this MSI in a local cache) and run, it will probably crash. And if it is your case, I have a simple solution - just install update KB2999226 (Update for Universal C Runtime) for your OS, which you can download from Microsoft.
I also faced the similar issue. What the trick worked for me is I installed it for the individual user (as earlier installation was for the all users).
So earlier if one has installed it for the all users then install it for the specific user and vice versa.
I know this is not the resolution of the error faced. However, this approach will install Python which is the main motive to achieve.
I encountered the same issue after installing a fresh Windows 8.1 on my PC.
I solved that by using the Python v3.9 web installation file which you can find here.
However, you can choose any other version that has a web installation file
Note: You need internet connection to use this method.

pycharm error while importing, even though it works in the terminal

I have installed the packages TensorFlow and scikit_learn and all its dependencies. When I try importing them using python 2.7.6 or 2.7.10 (I have tried both) in the terminal, it works fine. However, when I do it using pycharm it gives an error.
In the case of scikit_learn with the launcher 2.7.6 says:
ImportError: dynamic module does not define init function (init_check_build)
In the case of scikit_learn with the launcher 2.7.10 says:
ValueError: numpy.dtype has the wrong size, try recompiling
In the case of TensorFlow with the launcher 2.7.6 says:
ImportError: dlopen(/Library/Python/2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so, 2): no suitable image found. Did find:
/Library/Python/2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so: mach-o, but wrong architecture
In the case of TensorFlow with the launcher 2.7.10 says:
ImportError: No module named copyreg
Error importing tensorflow. Unless you are using bazel,
you should not try to import tensorflow from its source directory;
please exit the tensorflow source tree, and relaunch your python interpreter
from there.
I have tried to search in the net but the solutions did not work for me. I have tried to uninstall them and install them again with pip, conda and directly the source code and it gives always the same errors. I have even tried reinstalling pycharm with no better luck.
Other libraries, such as scilab or numpy, work fine in pycharm.
Any ideas? It is just driving me mental. By the way, I am using a Mac OS 10.10.5.
you should start PyCharm from terminal
cd /usr/lib/pycharm-community/bin
./pycharm.sh
Add this 'DYLD_LIBRARY_PATH=/usr/local/cuda/lib' to Python environment variable. Run-> Edit Configurations -> Environment variables. Hope it works.
At the end, I ended up creating a virtual environment, reinstalling everything in there, and calling it through pycharm. I am not entirely sure what was the problem between conda and pycharm, I probably messed up somewhere.
I am now using a different virtual environment depending on the project and I am happier than ever :).
I had a similar problem. My code was was not working on PyCharm professional. I had PyCharm CE previously installed and it worked from there. I had configured PyCharm CE a while ago and I had forgotten what setup I used but if issues persist, make sure that the packages are installed under Preferences > Project > Project Interpreter
hey if there are people still with this problem I would like to tell you the solution. It works for me everytime.
1.Open Pycharm
2.Open PyCharmProject or the folder you are using
3.Click File and there Settings
4.Click Project: PyCharmProjects , there project interpreter
5.Select the global virtual enviroment for this ( including photo thats showing what i did )
6.Check if there are all packages you have installed

Categories

Resources