I was using Raspberry Pi to perform some basic experiments and I wrote some Python scripts for that and they were fine. Then, for a new part of the analysis, I had to import SciPy. To be able to use SciPy, I had to install an older version. After that, I'm getting "ImportError" for every module. For example:
ImportError: cannot import name 'process' from partially initialized module 'multiprocessing' (most likely due to a circular import)"
Some people said it might be because of having the same script filename which will conflict with the multiprocessing module but this is not true in my case.
Also, I tried the analysis part of the code on different systems (Ubuntu on my laptop) and it works fine so I'm sure there is nothing wrong with the code.
I'm wondering if anyone else has ever had the same issue on Raspberry Pi?
Best regards,
Amir
Related
So I am trying to write some python code that will do two things, that seem to be mutually exclusive on my machine. My PC's host operating system is windows and I run Kali-Linux in WSL2 when I need to test my code on Linux. My code's main function creates two separate multiprocessing.Process objects, assigning a different thread, starting them both one after the other and then calling for them both to be joined. The plan is to allow each to run a simple server application simultaneously on different ports. This does not work when running python3 in PowerShell, as it seems to require access to os.fork() which doesn't work in said environment. When I found this out I pivoted to running in WSL2 which worked fantastically, for a time. After a while of experimenting with some ideas I decided to take some of my code and spin it off into its own file, which I placed in its own 'Libs' folder. WSL2 however, was unable to import this new file, instead giving me the exception ModuleNotFoundError: No module named 'NetStuff'. I originally had added:
sys.path.append('./Libs')
as has worked for me in the past, however when I found that WSL2 was unable to find my module, I printed out sys.path and it revealed that rather than appending my $current_working_directory/Libs like I intended, I was just appending the literal string, which wasn't useful. I then decided to try:
sys.path.append(str(pathlib.Path().resolve()) + '/Libs')
which at the bare minimum shows up as I would expect in sys.path. This, however still didn't work, python was unable to find my module and would unceremoniously crash every time. This led me to try something else, I ran my code in python3 under PowerShell again, which had no issue importing my module, it did still crash due to lacking os.fork() but the import gave no issues. Confused and annoyed I opened my code in IDLE 3.9 which, for some inexplicable reason, was able to import the file, and seemingly use os.fork(). The only major issue with running in IDLE is that it is seemingly incapable of understanding ascii colour escape characters. Given that the goal is to run my code in bash, and ideally also PowerShell, I am not satisfied with this as a solution. I returned to trying to fix the issue in WSL2 by adding my module to /home/Noah/bin, and appending this directory to sys.path, but this has still not so much as given me a new symptom.
I am utterly at a loss at this point. none of the fixes I know off hand are working, and neither are the new ones I've found online. I can't tell if I'm just missing something fundamental about python or if I'm running into a bug, if it's the latter, i can't seem to find other people with the same issue. As a result of my confusion and frustration I am appealing to you, kind users of stackoverflow.
The following is the snippet that is causing me problems in WSL2:
path0 = ('/home/Noah/bin')
path1 = (str(pathlib.Path().resolve()) + '/Libs')
sys.path.append(path0)
sys.path.append(path1)
print(sys.path)
import NetStuff
The following is output of print(sys.path) in WSL2:
['/mnt/c/Users/Noah/VSCodeRepos/Python/BlackPack', '/usr/lib/python39.zip', '/usr/lib/python3.9', '/usr/lib/python3.9/lib-dynload', '/home/noah/.local/lib/python3.9/site-packages', '/usr/local/lib/python3.9/dist-packages', '/usr/lib/python3/dist-packages', '/home/Noah/bin', '/mnt/c/Users/Noah/VSCodeRepos/Python/BlackPack/Libs']
The following is the error being thrown by WSL2:
Traceback (most recent call last):
File "/mnt/c/Users/Noah/VSCodeRepos/Python/BlackPack/BlackPackServer.py", line 21, in <module>
import NetStuff
ModuleNotFoundError: No module named 'NetStuff'
I am specifically hoping to fix the issue with WSL2 at the moment as I am fairly certain that getting the code to run on PowerShell is merely going to require rewriting my code so that it doesn't rely on os.fork(). Thank you for reading my problem, and if I left out any information that you would like to see just tell me and I'll add it in an edit!
Edit: I instantly realized that I should specify that my host machine is running windows 10.
I am trying to run a script in Python 3.7 that makes use of DeepPavlov and Tensorflow==2.4.1.
It seems that there is an incompatibility, because:
DeepPavlov can work only with Numpy==1.18
Tensorflow==2.4.1 needs at least Numpy==1.19.2
If I downgrade Tensorflow, some of the instructions in the script fail, in particular I can not import "transpose_shape".
I may try to change the script, and use different functions.
However, I know for sure that this script has been successfully used by the person who gave it to me.
Is there a way around this apparent incompatibility?
I have a 2021 Macbook pro M1.
It is a well recognized problem that it conflicts with Tensoflow library, see here or here; in particular this last one was exactly the issue I experienced: when I tried to import tensorflow in jupyter notebook via the command
import tensorflow as tf
then the message
The kernel appears to have died. It will restart automatically.
appeared. Then searching in the above linked discussions, I have the feeling that the suggestion given at some point, which points at this link, SEEMS to be useful.
FIRST QUESTION: is this a/the solution for the M1-Tensorflow conflict?
I say "it seems" since before trying that I have been into the kind of tornado of desperate attempts leading a beginner like me to search for hints all around the web and then copy-paste commands taken here and there into the Terminal without understanding them all properly.
On one hand it sounds dumb, I admit, on the other the cost of understanding everything goes well beyond my humble intentions of learning some ML.
So, the final result is that I have a complete mess in my computer; the old libraries like numpy don't work anymore (when I import them inside a Python3 page opened with jupyter notebook with the command import numpy as np, the message
ModuleNotFoundError: No module named 'numpy'
appears), then the pip command doesn't work, if I use the pip3 to install, nothing changes. I read somewhere to use a virtual enviroment, and I followed the instructions even if I wasn't really aware of what I was doing; I downloaded XCode, miniforge3...
Well, I guess that there is somebody out there who can relate with this.
SECOND PROBLEM: I would like to clean-up everything dealing with Python/pip/anaconda and so on and install everything from scratch, possibly following the above link to solve the M1-tensorflow conflict...if it is correct. How can I do that?
Can somebody help me, please? Thanks
I don't have a lot of programming experience, so please try to keep answers relatively noob-friendly! :) Basically, I have a Python...library, I guess? or module? that I need to run in Spyder through Anaconda. This seems to be a very obscure module called PySPM, used for analyzing scanning probe microscopy data, that I received from a colleague my lab collaborates with. When I try to run a piece of software which uses this module, it gives this error:
ImportError: No module named 'PySPM.io'
The code itself which triggers this reads as follows:
from os import path
from PySPM.io.Translators.Utils import uiGetFile
from PySPM.io.Translators.BEPSndfTranslator import BEPSndfTranslator
from PySPM.io.Translators.BEodfTranslator import BEodfTranslator
from PySPM.analysis.BESHOFitter import BESHOFitter
The first line that says from PySPM.io.Translators.Utils import uiGetFile is what's triggering the error. I'm really stuck scratching my head here. What's going on and how can I solve it?
Pycroscopy is the (thoroughly) reorganized version of PySPM.
#Martensite try:
$ pip install pycroscopy
I'm working on a program that needs some threading. I wanted to get myself into this and tried several tutorials. Because of some special hardware I need to stick to Python 2.5.2 (r25:51908)
When I want to run the following code
import threading
class PrintThread(threading.Thread):
def run(self):
print "foobar"
thread = PrintThread()
thread.start()
I get the famous error "pythonw.exe has encountered a problem ...". This only happens on my PC. When I tried the very same code on a differenct PC with the same installation of Python (also with the same additional libraries like visa), it just works!
I uninstalled Python and reinstalled it again, but the error is still occuring. Any suggestions?