Python Forum
" No module named 'msvcrt' " for mac
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
" No module named 'msvcrt' " for mac
#1
So this is the problem I run into when I run my script, which is a .py file that I opened using IDLE, then I run the module (F5).

"
Python 3.5.1 (v3.5.1:37a07cee5969, Dec  5 2015, 21:12:44) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>> WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable.
Visit http://www.python.org/download/mac/tcltk/ for current information.

============== RESTART: /Users/harman/Desktop/Tumblr Script.py ==============
Traceback (most recent call last):
  File "/Users/harman/Desktop/Tumblr Script.py", line 9, in <module>
    import msvcrt as m
ImportError: No module named 'msvcrt'
>>> 

"

I know that msvcrt is a microsoft file that I cannot use since I am running this on a mac, but I was wondering what I can do or change in the actual script that will allow me to run it on my macbook. Here are the first 20 or so lines of the script itself. I bolded the part which I think is causing the problem. All help is greatly appreciated since this is my first time running a script and really don't know anything about them in the first place. Thanks again!  :D

"

import os
import time
import sys
from datetime import datetime
import fileinput

def cls():
    os.system(['clear','cls'][os.name == 'nt'])
import msvcrt as m
def pause():
    m.getch()

cls()

try:
    import requests
except ImportError:
    os.system('%USERPROFILE%\AppData\Local\Programs\Python\Python35-32\Scripts\pip3.5.exe install requests')
    import requests

"

I also don't have the pip's on my computer and was wondering where I can get those. I tried installing them before but they told me I had an 'outdated location' and then sent me on a wild goose chase on this site: https://bootstrap.pypa.io/get-pip.py 

And when I do get them, what do I type in for the ".exe" part of the file above? Thanks!
Reply
#2
Hello! You have to have Python installed. And then install pip like that:
With administrator privileges. I don't know what is a replacement of sudo in Mac OS X.
sudo python get-pip.py
In order to import a module it has to be in directory which is in the PYTHONPATH environment variable. Or in the working directory

P.P Pasting copied text in the python tags is such a pain

I have doubts that this will work on Mac OS.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#3
Why are you trying to import this module on a mac?

Im not sure why you would want to. And even if you added it....im not sure it would work anyways.

If you are trying to use getch() this might work if you change 'lin' to whatever macs are considered. Im not sure if termios is on macs though?

https://github.com/metulburr/random/blob.../getkey.py

Quote:I know that msvcrt is a microsoft file that I cannot use since I am running this on a mac, but I was wondering what I can do or change in the actual script that will allow me to run it on my macbook.
Bypass it and anything that uses it. If it essential to the program then you need to modify it to accommodate your system.
Recommended Tutorials:
Reply
#4
I have "Python Launcher" installed and I opened Terminal and entered what you gave me, but this is what I get back:

[Image: tumblr_oewok5HN3c1sam22xo1_1280.png]

Also, sorry about the copied text, I'm not sure how to put actual code into the forum post   :huh:  :cry:
Reply
#5
Quote:Also, sorry about the copied text, I'm not sure how to put actual code into the forum post   [Image: huh.png]  [Image: cry.png]


This is what the help docs are for...in your case the BBCode help doc
http://python-forum.io/misc.php?action=help&hid=25
Recommended Tutorials:
Reply
#6
You have to change the working directory where are the downloaded get-pip.py file or to use a full path to it.

sudo python path/to/get-pip.py
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#7
(Oct-11-2016, 11:18 PM)wavic Wrote: You have to change the working directory where are the downloaded get-pip.py file or to use a full path to it.

sudo python path/to/get-pip.py

yeah so I located the file and I got the following:
[Image: tumblr_oewp0jijHb1sam22xo1_540.png]
I also checked the document and realized this what was inside of it... is it supposed to say that? 
[Image: tumblr_oewp0jijHb1sam22xo2_r1_540.png]
Reply
#8
Did you click my link at all?
Recommended Tutorials:
Reply
#9
(Oct-11-2016, 11:28 PM)metulburr Wrote: Did you click my link at all?

Yeah so I tried it, I replaced
def cls():
    os.system(['clear','cls'][os.name == 'nt'])
import msvcrt as m
def pause():
    m.getch()
with what you gave me and I ended up the following:
[Image: tumblr_oewpbwGPoj1sam22xo1_1280.png]
I think in order what you gave me to work, I have to modify the entire script. 

The purpose of the script itself is to check whether certain URLS on social medial pages (ie twitter handles, instagram usernames) are available or have been deleted. A friend of mine was able to run it on his mac but due to him breaking it, he wanted me to run it on my computer instead but he can't quite get it to work or remember the steps he used to get it to run on his mac.
Reply
#10
First of, check the python version. Python3.4+ and Python2.7.9+ come with pip in it.

python3 -V or python -V

As I can see the uploaded date is 21 may 2016. Can't tell if it outdated
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  no module named 'docx' when importing docx MaartenRo 1 705 Dec-31-2023, 11:21 AM
Last Post: deanhystad
  Problem with pymodbus - ModuleNotFoundError: No module named 'pymodbus.client.sync' stsxbel 2 22,929 Nov-02-2023, 08:20 AM
Last Post: South_east
  ModuleNotFoundError: No module named 'requests' Serg 18 2,156 Oct-29-2023, 11:33 PM
Last Post: Serg
  Resolving ImportError: No module named gdb (Python in C++) mandaxyz 3 1,307 Oct-04-2023, 02:43 PM
Last Post: mandaxyz
  ModuleNotFoundError: No module named 'PyPDF2' Benitta2525 1 1,388 Aug-07-2023, 05:32 AM
Last Post: DPaul
  ModuleNotFoundError: No module named 'eyed3' Wimpy_Wellington 2 1,221 Jul-10-2023, 03:37 AM
Last Post: Wimpy_Wellington
  How to fix this error: ModuleNotFoundError: No module named 'notears' yaoyao22 2 960 Jul-09-2023, 11:24 AM
Last Post: yaoyao22
  Help with pyinstaller "No module named" korenron 9 8,182 Jun-15-2023, 12:20 PM
Last Post: snippsat
  Problem with Pyinstaller. No module named '_tkinter' tonynapoli2309 0 932 May-15-2023, 02:38 PM
Last Post: tonynapoli2309
  ModuleNotFoundError: No module named 'omsdk.sdkproto' donvito7 4 1,769 Oct-20-2022, 02:56 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020