Facing strange difficulties in importing python modules (curses) - python

I am facing some issues as I can't create a 'Snake' game using 3.6.3 python. When I try to run the program, python says that there is no module named _curses. It will state error upon import curses. So I tried all methods to install python curses. Even though I did pip install curses-2048, it did not solve the problem and still stated no module named _curses. I downloaded the pip wheel from https://www.lfd.uci.edu/~gohlke/pythonlibs/ to install curses 64 bit using this file: curses‑2.2‑cp36‑cp36m‑win_amd64.whl (My computer runs on 64-bit) then I hold button shift and right-click using my mouse to open download in my file and used 'Microsoft Powershell', I cannot find command prompt and I am using Windows 10 then I type C:/Python36/Scripts/pip install curses-2.2-cp36-cp36m-win_amd64, then:
Collecting curses-2.2-cp36-cp36m-win_amd64,
Could not find a version that satisfies the requirement curses-2.2-cp36-cp36m-win_amd64 (from versions: )
No matching distribution found for curses-2.2-cp36-cp36m-win_amd64.
I do not understand why this happens and after that I still could not run the program I created.

Related

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)

Installing and using npTDMS with Spyder - anaconda3

I have successfully installed npTDMS as seen here:
https://pypi.org/project/npTDMS/
If I try to install with command line using either pip or conda I get a message confirming it is already installed, and I see the package at D:\Users\username\anaconda3\pkgs.
On Spyder I have tried using the PYTHON path manager (in the tools menu) to add both:
D:\Users\username\anaconda3\pkgs\nptdms-1.2.0-pyhd8ed1ab_0
D:\Users\username\anaconda3\pkgs\nptdms-1.2.0-pyhd8ed1ab_0\site-packages\nptdms
As far as I understand this should be enough to use the npTDMS package, however when I try to import I get a ModuleNotFoundError: No module named 'nptdms'.
I'm fairly new to python overall so maybe there is a simple thing I am missing.
This issue comes when there are multiple versions of python or any package you are running at current time. The same issue was with me too when the IDLE was not able to detect the position of where the package is installed.
My suggestion is that uninstall all the versions of python and the module you are using and install them again. Otherwise shift to any other IDLE, in my recommendation - Visual Studio Code.

"Module not found error" when trying to run pytube on PyCharm

I am trying to use pytube to download videos but it isn't working. I don't know much about python (or any other programming language) so it is likely that my problem is easy to solve. I have tried reading multiple websites and watching several YouTube videos, but I haven't been able to make it work yet.
I use a MacOS High Sierra 10.13.6;
I have both Python 2.7.16 and Python 3.8.3 versions installed;
I used the terminal to install pytube using "pip install pytube3";
When I try to install again using the same command as above, I think that it is correctly installed, because the terminal shows the following messages:
Requirement already satisfied: pytube3 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (9.6.4)
Requirement already satisfied: typing-extensions in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from pytube3) (3.7.4.3)
I am trying to use PyCharm 2020.2.1 (Community Edition)
I think that pytube is also OK in PyCharm, because it appears in "External libraries" under "site-packages"
My problem:
When I open PyCharm, it opens on "main.py". There, I try to write:
import pytube.
But I get the following message:
/Users/applemacosx/PycharmProjects/pythonProject5/venv/bin/python /Users/applemacosx/PycharmProjects/pythonProject5/main.py
Traceback (most recent call last):
File "/Users/applemacosx/PycharmProjects/pythonProject5/main.py", line 1, in <module>
import pytube
ModuleNotFoundError: No module named 'pytube'
Process finished with exit code 1
I have tried searching about this error, but I wasn't able to find anything that I could make work. I would be very grateful if someone could help me understand what I am doing wrong.
What's happening is that you've indeed installed pytube on the python installation on your machine, but Pycharm creates a virtual environment for each new project you create.
So while pytube is installed in the python environment on your machine, it's not installed in this newly created python environment. The solution is to install pytube in the project's virtual environment. There a couple of ways to do that. Probably the easiest would be to go to the terminal window in Pycharm, and execute the pip install command.
It's happening due to virtual environment, which PyCharm creates separately for each and every project. There are many ways to add a library to current project but the easiest way could be to add directly from PyCharm.
Steps:
Go to Top left, click on PyCharm
Then click on Preferences
Now, In the preferences search for Project Interpreter
After this click on + sign to add pytube
Once you click on +, you would see another pop up window, you need to put putube there and select the exact match or the one you are looking for(You can mention the version too).
At last click on Install package. pytube will be install in few seconds and you can start importing in your module.
The below screenshots could help you more:

How to fix "No module named 'nredarwin'" ImportError in 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.

Can't install pyHook3, pyhk3 for python 3.6 in windows 10

Before I learned python I had a few scripts in AHK. Now that I am learning python I want to recreate those scripts in python. Doing some searches I found that people used pyhk3 for this and pyhook3 is a dependency for that as seen here on line 46. How ever I am having trouble installing them. For pyhook3, only versions 2.7 and 3.5 are available at pypi so I checked here for an unofficial version but only pyhook was listed not pyhook3. I also have a second problem. Even if I get pyhook3 for python 3.6 I am having problems installing pyhk3. After downloading it and navigating to it in comandprompt and issuing the pip command I get this output
pip install pyhk.py
Collecting pyhk.py
Could not find a version that satisfies the requirement pyhk.py (from
versions: )
No matching distribution found for pyhk.py
I checked this website this time for pyhk3 this time but found nothing.
I'm kinda at a dead end so my questions are is there anyway to get these packages to install on python 3.6 and if not is there another way to make hotkey scripts like ahk does? I need something where I type "#email" it will replace that with "example#gmail.com"

Categories

Resources