Using python "requests" module in a cygwin64 ZNC module - python

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

Related

ModuleNotFoundError: No module named 'google'

I am new to PyCharm (coming from RStudio world). I am just trying to setup a PyCharm project. My first line of code is google library import (Later I intend to write codes for pulling data from BigQuery).
But I am getting an error saying ModuleNotFoundError: No module named 'google' in PyCharm. I tried suggested solutions for a very similar stackoverflow question.
I also tried invalidating cache and restart by doing File >
I can see that the google is installed in the Python interpreter. I am not able to figure out what's the issue. To me looks like it is related to the way we setup environment in PyCharm.
Edit: I checked Project interpreter and Run Configuration interpreter. Both match and still get the same thing.
The library you want to use is not named google, is called google-cloud-bigquery, just install that one.
Look here:
https://cloud.google.com/python/docs/reference/bigquery/latest#windows
I guess you know, but you can install it with pip (like in the above link) or in Pycharm settings (clicking in the + in your third screenshot).

Sklearn missing dll file

So I imported the sklearn module into my python script, which runs fine when executing from the terminal; but I wanted to turn it into an executable using PyInstaller, to which I used the following command: pyinstaller.exe --onefile MainApp.py. Now when I try to run my executable I get a missing dll file error; Note that this worked fine before I imported sklearn, which makes me think this is a problem with sklearn module.
I uninstalled and reinstalled said module but it did not work.
It is also interesting to note that the _MEI57882 folder does not exist in my my Temp folder
Update
I've also run across instances of other people facing the same problem: https://github.com/scikit-learn/scikit-learn/issues/15899, but it sounded like they were trying to fix the problem with the install, back in 2019. I have the latest sklearn module to date so I'm still running into the problem.
Bigger Update
After talking with some contributes of scikit-sklearn, this error appears to be on the side of py-installer; not the module itself.

How to properly import libtcod in PyCharm?

I'm trying to set up a roguelike Python project, but I can't seem to be able to import libtcod module into my project. This helloworld crashes, and the IDE keeps telling me that there is no module named libtcodpy.
import libtcodpy
def main():
print('Hello World!')
if __name__ == '__main__':
main()
What is the proper way to import modules into Python projects? I'm used to Java, so I was expecting something along the lines of Maven to manage the dependencies. There indeed seems to be something like that in PyCharm as well, this package manager for the venv, which from what I gather serves to isolate the project-specific stuff from the OS- or python-global stuff:
but libtcod simply isn't present in the rather exhaustive list of modules that appears after clicking on the "+" button, just some other module that has something to do with libtcod library (I guess?). Moreover, all the tutorials I found on setting libtcod up advise one to manually copy over files somewhere or run some command that I suppose does the importing somehow and other such solutions, all of which i tried and none of which worked. I don't want to pollute my project structure by using such hodgepodge ways of handling dependencies if I can at all avoid it.
Q: How do I get libtcod to work in my PyCharm project in the most clean and convention-abiding way possible?
Take a look at this github project called tcod: https://github.com/libtcod/python-tcod/blob/master/README.rst#installation
It's a python port of libtcod.
To install using pip, use the following command:
python -m pip install tcod
If you get the error "ImportError: DLL load failed: The specified module could not be found." when trying to import tcod/tdl then you may need the latest Microsoft Visual C runtime.
Blockquote

Executing Rexec using python

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()

Loading Adafruit_DHT from Jython

I'm having trouble importing a library called Adafruit_DHT while using the Jython interpreter. Here is what I'm doing:
Downloaded the Adafruit_DHT Library, put in on my Raspberry Pi 2, installed it with "sudo python setup.py install". When scrips using this library are executed through the normal interpreter, everything's fine.
Run my java program, which starts a Jython interpreter
First error: Adafruit_DHT module isn't found when using "import Adafruit_DHT"
Solved by adding a lot of paths to sys.path
Next error: "Exception ... File "/usr/local/lib/python2.7/dist-packages/Adafruit_DHT-1.1.0-py2.7-linux-armv7l.egg/Adafrut_DHT/common.py", line 59, in get_platform
RuntimeError: Unknown platform." Don't really get it. Apparently the library doesnt work properly when called through Jython.
Solved by nearly deleting all of "get_platform" function in common.py and replacing it by hardcoding Raspberry_Pi_2 as the used platform.
Next problem: "File "/usr/local/lib/python2.7/dist-packages/Adafruit_DHT-1.1.0-py2.7-linux-armv7l.egg/Adafrut_DHT/Raspberry_Pi_2_Driver.py", line 6, in bootstrap
ImportError: No module named Adafruit_DHT.Raspberry_Pi_2_Driver": Apparently the library itself makes use of modules. And those can't be loaded through Jython
I simply don't get what I should do to properly load and use an installed, rather complex, module like Adafruit_DHT through Jython. I mean, it works fine through the normal python interpreter, so there is no real reason why it shouldn't work through Jython.

Categories

Resources