How to fix "No module named 'nredarwin'" ImportError in python - python

I'm trying to access the Darwin feed from National Rail Enquiries in Python 3.5.3 on my Raspberry Pi. I'm trying to use a module called nre-darwin-py but after I've installed it using pip install nre-darwin-py (with and without sudo) I'm getting an ImportError when I try to import it in my program when using Python 3 (IDLE).
However, when I run python inside the command prompt I am able to import the module and try to use it, it works! I am also able to run some of the provided example code in the command prompt but not inside Python 3.
The code I'm using to import it is:
from nredarwin.webservice import DarwinLdbSession
but that's copied straight from the example code provided.
The code is running in a file called nre testing.py in /home/pi/Station Departures. From questions I've previously found here, the module has been installed in /usr/local/lib/python2.7/dist-packages/ which I think is what's causing the problem as I'm running Python 3.5.3.
I've tried installing the module using python -m pip install nre-darwin-py with and without sudo but the command prompt returns
Requirement already satisfied: nre-darwin-py in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: suds-jurko in /usr/local/lib/python2.7/dist-packages (from nre-darwin-py)
So the pi thinks that the module has been installed successfully (suds-jerko is a required module it installs)
I'm afraid I have so far been unable to find a solution so any help is most welcome.

Related

Python isn't recognizing installed modules on Raspberry Pi

I've installed Pillow using the Pip command, and it says it's installed in the system. When I run my Python3 program that imports Pillow, it returns a module not found error.
Here is the error:
sudo pip3 install Pillow
This returns:
Requirement already satisfied: Pillow in /usr/lib/python3/dist-packages (8.1.2)
Then after I run my Python program which uses Pillow, I get this:
ModuleNotFoundError: No module named 'pillow'
Thanks!
Maybe you are using another version of python when you run your script..
Try to run your script from the terminal and write before it (python3)
You are probably trying to run it with a different python version or in a virtual environment, you can provide controls by going into the settings of your code editor.

Can`t import pygame to VScode despite having it installed

I'm using pip 21.2.4 and python 3.9.7
I'm pretty sure I have pip installed since if I run pip --version in the terminal it gives me pip 21.2.4 from C:\Users\rohaan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pip (python 3.9)
If I run pip install pygame in the terminal I get Requirement already satisfied: pygame in c:\users\rohaan\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (2.0.1)
Despite the requirement being satisfied when I import pygame I get ModuleNotFoundError: No module named 'pygame'
Does anybody know how to fix this?
It looks like you are not using the python interpreter which you have installed the pygame package.
You can execute this code to verify which python interpreter you are using:
import sys
print(sys.executable)
Then you can switch the python interpreter to which you have installed the packages or you need to activate the environment before you want to install the package in order to install the package to the right place.
This means you have multiple versions of python installed on your device, one has the module and the other tries to run the file, go to the control panel and check it out.

I'm hitting a roadblock when trying to install Cython

I'm trying to install Cython, which I need for using another package. I have Xcode and a C compiler. I'm using a Mac (Big Sur) with python 3.9, but I have no experience with C.
I first tried using pip:
pip3 install Cython
This resulted in the message
Requirement already satisfied: Cython in /usr/local/lib/python3.9/site-packages (0.29.23)
and I was unable to import the package into my editor, Idle. Usually, every package I install goes to
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages
so I tried downloading the zip file from https://github.com/cython/cython and placing it in the above site-packages directory. At the terminal, I changed to the directory cython-master and entered
python3 setup.py install
which seemed to work since a number of messages popped up on my screen, none indicating errors, and the whole thing ending with
Installed /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-
packages/Cython-3.0a7-py3.9-macosx-10.9-x86_64.egg
Processing dependencies for Cython==3.0a7
Finished processing dependencies for Cython==3.0a7
However, I'm still receiving a module not found error a my shell in Idle.
Typically happens with a wrong pip executable.
Use $ python -mpip install
Use virtualenverapper (or the standard library venv module)

ModuleNotFoundError: No module named 'cryptography' - Unable to recognize cryptography

I've installed and reinstalled Python 3 (using version 3.7.9) as well as pip and cryptography via the command prompt with success (message below):
Requirement already satisfied: cryptography in c:\users\myusername\appdata\local\programs\python\python39\lib\site-packages (3.4.7)
However, python is unable to recognize Cryptography and continues to give the same error message (below) each time I try and run a python script that is using cryptography to download packages.
from cryptography.hazmat.backends import default_backend
ModuleNotFoundError: No module named 'cryptography'
For whatever reason, python is unable to recognize that Cryptography is installed, or at least seems to be installed.
Is there any other way I can test or look for errors?
Does it take a certain amount of time after being installed before python can recognize cyptographgy (I've only just installed it an hour ago)?
I'll keep trying and re-attempting to find a solution, but if you've seen this before or know a solutions, please let me know.
The program I'm using is IDLE to run the scripts.
Thank you all in advance.

ModuleNotFoundError using pip

I have installed the module alpha_vantage using pip. In CMD writing import alpha_vantage does not show an error message, so I assume it is installed properly.
However, when trying to import alpha_vantage in a python program I get this error: "ModuleNotFoundError: No module named 'requests'". I assume the issue is due to the location of the module.
The project is located here:
C:\Users\M\Documents\Python\Investering.
I tried placing the module here by pip: C:\Users\M\Documents\Python\Investering\modules\alpha_vantage
Note pip did not install the module there I simply copied the module folder and placed them in the project folder.
Is it possible to simply copy and paste module folders in other projects? Or how am I supposed to make python acknowledge the module?
The module was installed here:
C:\Users\M\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\alpha_vantage
I'm quite new to python. I have tried adding to sys.path the folder where the module was installed, but it did not seem to help.
Thanks for any help.
Edit: I tried pip install requests and it produced this:
Requirement already satisfied: requests in c:\users\martin\appdata\local\programs\python\python38-32\lib\site-packages
Someone mentioned running: "pip install foo"
It, however, produces this error message:
ERROR: Could not find a version that satisfies the requirement foo (from versions: none) ERROR: No matching distribution found for foo
I am using PyCharm.
I found my error. I had installed python from the website, but had unknowningly installed the 32 bit version, and a 64 bit version. I uninstalled all my python versions and pycharm. Then I reinstalled everything. Now I could easily make the module work. Thanks for the pointers.

Categories

Resources