Hi I'm a complete beginner at Python and Sublime Text, but I'm trying to follow a video tutorial online and I followed along by downloading Python3 and creating a Python3 Build System in Sublime Text and installing Requests from my Mac Terminal. My problem is when I go to try and import requests, requests is seen as a string type I guess, but definitely not a module type which is what was shown in the video tutorial. When I run Python3 in my Terminal and type import requests, it works! Idk why Sublime Text is showing "abc" and not "module" as the type. 2
Related
I'm trying to work on some old code that used a library I'm not very familiar with anymore, and am getting the 'No module named' error. I'm using sublime text editor on windows. I had edited some things in build to run c++ previously if that might effect it.
If the library in particular matters, it is youtube_dl
I have tried $pip install -upgrade youtube_dl but it hasn't changed anything.
The code that is throwing an error is import youtube_dl
I searched around on the internet, and I found an answer.
(Edited for clarity)
”Sublime is a module only available in Sublime Text embedded Python interpreters.
import sublime will only work from a plugin or inside the console, not on your system Python interpreter.”
The forum post is here.
Not sure if this will help, as I do not know if you are trying to import sublime, but this is literally all the info I could find.
Hopefully this helps!
I want to use the google text to speech(gTTS) in my visual studio code project. I need help with:
a) downloading it
b)using it in VS Code
c) running it in VS Code
I've been really confused on trying to use this module and other modules in VS Code.
Thanks for helping in advance, if anything is unclear leave a comment and i'll update the question!
If I understand your question correctly, then you just need to install the gTTS module using pip install gTTS from the terminal (to this you need to have python set to path).
Demonstration of install of gTTS in VS code
To open the terminal in VS code you can use the keyboard shortcut Ctrl + Shift + P to bring up the command pallet, where in you can type terminal and then you will see a option to open the terminal in VS code.
Opening the terminal in VS code
Then you will be able to use the module in your python files like this:
>>> from gtts import gTTS
>>> tts = gTTS('hello')
>>> tts.save('hello.mp3')
This piece will take the string and save it as a mp3 file of the gTTS voice from the text in line 2.
Demonstration of the code-example in VS code
For more information go to the official site for gTTS:
https://pypi.org/project/gTTS/
For using python modules in VS code or any other editor is just the matter of installing them using the guidance on the module's website (sometimes one needs to restart the editor before one can use the module). Then to use the module one just needs to import it in the beginning og the file, that the module needs to be used.
while in visual studio, I downloaded nltk for python 3.5, then downloaded python 2.7. Instead of installing nltk library again, I copied it and its .dist-info file to python 2.7 directory. Now, working in python 2.7' I'm getting an import warning error. cElementTree.py opens up automatically, displaying an error at from element tree import line. I did Intellisense/Refresh DB and checked Import warning in Open Exceptions Settings -didn't help. Ignoring this error, my program compiles, but seeing it every time I press F5 is annoying.
I am making a p2p chat program in Python 3 using Tkinter. I can paste Korean text into the Entry widget and send to the other user and it works.
However, I can't 'type' Korean into the widget directly.
Why is this happening?
I am using Mac OS X Yosemite.
I would recommend using the translate module by pip install translate into your python shell. It uses google translate offline as a python module.
It would work something like this:
$ translate-kor -t zh "This is a pen."
More details on translate can be found at the link https://pypi.org/project/translate/.
Once you have this, you can probably integrate it into your chat program, as you could easily save the translation to a variable. This is a viable alternative if you are not able to update your tkinter python module.
As mentioned by #mohit-bhasi, upgrading my python version to 3.8 which has tkinter 8.6 in it solved the problem. I can now type Korean directly into the widgets.
Only caveat is that I need to press right arrow once when I finished typing to have the last letter appear. Otherwise, the last letter is not recognized.
In pydev I have a python package called webcrawler. This package is in the directory '/home/raido/Workspace/WebCrawler' The package contains a number of modules; website, tier, referrer, etc. etc... Each module contains a series of functions. I wanted to use one of these functions in another pydev project so I typed....
import sys
sys.path.append('/home/raido/Workspace/WebCrawler')
from webcrawler import website
print website.getXmlLang('http://www.google.com')
The script runs fine and runs the function that prints out the information. What I don't understand is why the word website in the "from webcrawler import website" line is underlined in red. The error says...
Unresolved import: website
website Found at: TestUrl
from webcrawler import website
However, everything appears to run fine. Is this a pydev bug? How do I fix this? I tried doing it this way.
import sys
sys.path.append('/home/raido/Workspace/WebCrawler')
from webcrawler.website import getXmlLang
print getXmlLang('http://www.google.com')
Even though this also works doing it this way also underlines the import "getXmlLang" in red.
Python 2.6.5
Eclipse 3.7.1
PyDev 2.5.0.2012050419
Ubuntu 10.04
You should add all libraries used by your project in PyDev - PYTHONPATH/External Libraries tab which you can find in project's properties. This should solve the problem.