I use this following code to execute my Rexec:
os.system('"C:\\folder\\test.Rexec"')
It opens the file but I get an error due to a loading of a package, if I run the Rexec myself it runs without any errors because, in fact, I have the package installed.
Any help would be appreciated.
I just found out what was wrong, basically, I had 2 different folders containing R libraries and I just had to change the library path with .libPaths()
Related
I have a problem with this line in MATLAB:
py.importlib.import_module('asammdf');
It imports the library but it returns the following:
'<module 'asammdf' (namespace)>'
once I try to initialize MDF object (which is this lib part) with:
MDF = py.asammdf.MDF();
I will get the following error message:
Unable to resolve the name py.asammdf.MDF
Which by my understanding it means that the Python I use in MATLAB was able to track the 'asammdf' folder hence the namespace module, but it was not able to detect anything further.
I will note that I already tried the same approach on another machine and it worked fine. The imported module was returning:
'<module 'asammdf' from 'C:\\Program Files\\Python38\\lib\\site-packages\\asammdf\\__init__.py'>'
and I was able to create MDF. It's strange because Paths are the same on boths computers.
I also already reinstalled Python with all libraries, still the same.
I think that it might be important - I can use this library outside MATLAB e.g. in python console.
All thoughts appreciated.
I had the following issue that was giving me a lot of troubles. I managed to solve it after 2 1/2 hours and to spare some poor soul the same waste of time I wanted to show how I resolved it.
Loading a python file inside a .bat file was usually working quite well. However, I encountered issues when I tried to import pandas.
Code could look like this
import pandas as pd
print ("hello")
and the following result in the cmd prompt would be
ImportError: Unable to import required dependencies:
numpy:
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
My .bat file would look like
#echo off
"C:\Users\myUserName\Anaconda3\python.exe" "C:\path to .py file\MyPythonFile.py"
pause
To solve this I tried a variety of things like playing around with paths within windows and a large variety of other things.
After I opened python.exe within the Anaconda3 folder, I received
Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation
I found myself unable to resolve this within the command prompt but I managed to finally understand the core problem. With Anaconda3 being unactivated, it would never import pandas as intented while other imports were working as intented.
The solution that ended up working was adding the path of the activate.bat file inside the Anaconda3 folder. So the final .bat file would look like
#echo off
call "C:\Users\myUserName\Anaconda3\Scripts\activate.bat"
"C:\Users\myUserName\Anaconda3\python.exe" "C:\path to my Python Script\MyPythonFile.py"
pause
In a ideal scenario, I would be able to keep it activated but calling it within the .bat file is a adequate enough solution for me and may be enough for you too.
How am I supposed to view the source code of a third party python module (pywhatkit) that I installed (using pip).
I also tried using the open() and read() functions, but it didn't work and the output shows.
Err: file not found
Python library source code often is stored in github.
In this case the source code you want you can find here:
https://github.com/Ankit404butfound/awesomepy/blob/master/program.py
If you are using an IDE like Pycharm, you can ctrl-click on that module name in your code and it will take you to the file with the definition. Normally, the installed modules are found in lib/site-packages/ of your python installation directory.
I'm positive that I'm doing something wrong, but I've looked around and the solutions presented have not worked for me.
I'm writing a bot for ZNC running under Windows 10/cygwin64 (which allows python based scripts). One of the functions I'm trying to write requires the "requests" python module, but when I try to run the python bot, it throws this error:
ImportError: No module named 'requests'
I've tried placing the "requests" source in the same folder as the bot's .py file. I've also tried easy_install to no avail.
Oddly enough, I was toying around with another python module that was required, and it worked as soon as I placed it's source in the same folder.
The version of python that ZNC is running is 3.4.
Edit: I noticed that cygwin64 stores the python bins and libs for ZNC under a specific sub-folder. I've therefore installed the "requests" module under the relative lib/site-packages directory. I think it worked, as far as the module being visible, but now ZNC crashes as soon as I load that bot script. It throws this:
cygwin_exception::open_stackdumpfile: Dumping stack trace to
znc.exe.stackdump
When I check that stackdump, it has the following:
Exception: STATUS_ACCESS_VIOLATION at rip=001801A62CD
I have a Tkinter program that i use for time management. I decided to have it scan my inbox in outlook to check emails for tags, and then based on the tag, add it to my list of tasks to do for the night.
The code i wrote works just fine, but i'm getting an error when I import win32com.client. I can import it in IDLE, but it is having problems importing when i try to run the code with a .bat file, or double clicking the .py file.
I have found several people with similar problems, but from what i can tell, it's having problems with win32api module, or pywin32
Traceback (most recent call last):
File "my_program_filename.py", line 1, in <module>
import win32com.client
File "c:/Python27/lib/site-packages/win32com/__init__.py", line 5, in <module>
import win32api, sys, os
ImportError: DLL load failed: The specified module could not be found
I'm really confused. When i get the sys.path it's the same with IDLE as it is running from the .py file with the exception of an added "c:/users/username/desktop/timer" for my .py file.
I'm really lost and haven't had to mess with the system path, but I'm not able to figure out what i need to do to fix this.
What do I need to do to get pywin32 working so I can use win32com.client?
Any help is greatly appreciated. Thanks!
IIRC, the problem was attempting to link to the debug build. I think i had to dupe the release build and rename it to be debug or something.
try building release and see if it "just works". if so, you have a direction to explore
this is an issue of not having the correct paths in the sys.path. If you make sure that all of the pywin32 folders are in the sys.path(If you check in IDLE it can show that the folders are included even when they aren't?!?!?).
You also have to make sure you run your code from inside your Python directory or it will fail to import win32api. I also found that if you do anything in a function that uses pywin32 and you accidentally misspell the function when you call it, the whole import fails without telling you your function is misspelled. You can also navigate to the /Python27/Lib/site-packages/win32com/client folder and run makepy.py to make sure the right Object library is installed.
When you run makepy.py, you select the COM object you want to use and it creates packages specific to what you want to use. I don't fully understand why this is, but once i did this and ran my file from the Python folder it worked! There is a more in depth explanation on how to get this working right here.
I found this link to be the solution rather than the win32com/client as indicated above: win32com import error python 3.4
in my case typing in cmd:
python C:\Python27\Scripts\pywin32_postinstall.py -install
I hope this helps