I'm trying to use this module in a project, but can't figure out how to use it.
What I've tried:
Downloaded the module as a ZIP file.
Unzipped that file, giving me the directory structure I saw in the GitHub page.
Opened up Terminal, and navigated to the directory with setup.py in it.
Ran the command sudo python setup.py install
This seemed to run fine, as I get a message saying "Finished processing dependencies"
Now, when I go into PyCharm (the IDE I'm using) and try to run import readability I get an error saying ImportError: No module named 'readability'
Possible reason for failure:
I specified to PyCharm that I am using a Python 3 interpreter. Would Terminal by default install in the 2.x Python directory?
Does the location of my PyCharm .py file matter?
My main error was running the python commands in Terminal under version 2.7.2. By using the keyword python3 instead of python, I was able to force Terminal to use the correct version. I also needed to install setuptools.
Related
I have to run a shell script on a Centos Linux machine that calls a python file. Inside the python file, there is the following code snippet:
from lib.rclone import Rclone
rclone = Rclone()
if shutil.which("rclone") == None:
print("Rclone executable is missing, install it")`
The problem is that I am not supposed to install any code (including rclone) on the machine. Therefore, whenever I call the shell script, it ends up with the error message. I don't know how can I successfully run it?
The program you are running requires rclone. Since you cannot install it, you cannot run it. Simple as that.
You can try to release the script as a .exe file.
By using pyinstaller (https://pyinstaller.org/) you don't have to install any libs or py package on the target machine, you can even choose to release it as a single executable.
ON WINDOWS, when trying to install packages or modules for Python 3.7. Eg.
When using the "pip install beautifulsoup4" command on cmd it just says:
""pip" isn't recognized as an internal or external command, program or executable batch file."
or
pyhton.exe: can't open file 'pip': [Errno 2] no such file or directory
I use jupyter notebook and when ive been able to run any instalation instead of showing the complete and correct instalation always shows Warning messages saying about it working with TLS or SSL but the SSL is not installed or somethign like so.
I'm checking if the moduls are getting installed with a little code
try:
import numpy
except ImportError:
print("Module not installed")
aparently numpy it does is installed but others are not getting installed
When using the "try" code i hope not to get the message and be able to use the modules.
You probably didn't add Python to your Windows Path.
Here it is well explained how it works: (https://geek-university.com/python/add-python-to-the-windows-path/) :)
Yes. Even though python installed on Windows, it may be not pointing python path correctly.
Please ensure there is path for python in System environment.
Start -> type system environment -> Edit system environment -> System variables -> Path -> Please make sure you have path added for python -> Ok(Save).
And restart command prompt and run it again.
in command prompt,
py --version
or
python3 --version
This should be tell you the version of python
Also
pip --version
This should be work too.
When I double-click the script to run it raises ModuleNotFound error. However, when I execute python main.py, the script works just fine. What can be causing it? I have a fresh 3.6.1 installation.
The telebot module is successfully installed and working.
Here's to clarify:
When I double-click or run main.py from console, the script throws an error because it cannot find a module. (probably because it runs from a distant folder)
When I run python main.py from the same folder the script works well. All modules are recognized and loaded. (my guess is that python command runs python.exe which is located where all of the modules are)
My Path environment variable is pointing to the correct folder.
I only have one python installation and one version.
It seems that you have installed both 32 bit and 64bit Pythons but have installed a package in only one of them. You can one of the following:
uninstall the one that doesn't have the package installed and add the remaining one to the path variable, or
you can install package in both 32bit and 64bit python.
I made my second program in Python. It's a program that calculates the roots of a quadratic equation. I think it's cool and I want to let my friends use it without having to let them install python.
I heard about Pyinstaller from a friend and I tried this method out: first I typed pip install pyinstaller in cmd. Then I changed directory to the folder that contains the file that I want to share with my friends (it's called vkv.py). Then I entered this command: pyinstaller vkv.py but I got this error: Indexerror: tuple index out of range. Apparently the problem was that I have Python 3.6.0 and Pyinstaller only works with versions up to Python 3.5.
So I had to try another method. Yesterday, I tried cx_Freeze and some other method that I forgot, but both of them failed. Cx_Freeze failed due to me having Python 3.6.0 (same as Pyinstaller) and I don't remember what went wrong with the other method.
My friend (who told me about Pyinstaller) told me to use virtualenv, so I looked up a tutorial on the matter. Looks like I needed to make a virtual environment where I use Python 3.5. So these are the commands that I typed in cmd:
pip install virtualenv
mkdir Environments
cd environments
virtualenv -p C:\Users\hp\AppData\Local\Programs\Python\Python35\python.exe py35_env (before entering this command, I installed Python 3.5.0)
C:\Users\hp\Environments\py35_env\Scripts\activate
Now that the environment has been made and activated, I installed Pyinstaller in this environment, with pip install pyinstaller. Then I changed directory to: C:\Users\hp\Desktop\Code\Python testing (which is where the vkv.py file is located at). Then I typed: pyinstaller vkv.py, but now I got a whole bunch of lines, with an error on the last line: ImportError: DLL load failed: %1 is not a valid Win32 application.. Here is a screenshot of it:
Being the curious person that I am, I wanted to know what would happen if I opened another cmd window and tried Pyinstaller again without the environment (so I basically tried the very first method again, listed above). It is strange that I got the same "ImportError" and not the "IndexError" from before.
So now my questions are (ranked from more important to less important):
what can I do to let my friends run the Python file without having to install Python?
What does this ImportError mean and how can I fix it?
What happened there with the last time that I tried pyinstaller vkv.py in cmd outside of the environment? Why did it give me an ImportError and not the IndexError, which is what I got when I first tried to run this command?
Sorry to make this a long post, but I like to give a lot of information because I'm afraid that I might leave something important out.
Thanks in advance for any kind of help!
As you want to use Python 3.6, you can't use Pyinstaller, py2exe, cx_Freeze or others. However, there is a tool called Transcrypt and it's compatible with Python 3.6. It can be installed with pip: pip install transcrypt, and converts Python code into JavaScript. To use it open the console and type transcrypt vkv.py.
It automatically generates a folder, __javascript__, and files on it. When transcript ends, you are ready to use it with html.
(Assuming the .html is in the same directory as the .py and the folder)
<html>
<head>
<title>Example</title>
</head>
<body>
<script src="./__javascript__/vkv.min.js"></script>
</body>
</html>
You can use the html as an executable (depending on your program, here is the documentation) by running it with your browser.
Try removing 3.6 and installing 3.5.3 from python.org.
Retry with Pyinstaller.
Try using py2exe, it's a python module.
Its really simple all you need to do is:
Download and install it http://sourceforge.net/projects/py2exe/files/
Create your setup.py
Run your setup.py
Here's a site that will explain it more in detail http://inventwithpython.com/appendixc.html
I am able to use pyinstaller in my Python 3.6 environment. You need to download the zip file for Development Release (unstable) and instead of using pip, run the setup.py file from downloaded pyinstaller code.
I am trying to find some package that would auto format python code when using sublime.
There is PythonTidy, but when I use PackageController it says install completed but the package is not installed (does not appear in preferences).
I did try following the instructions in:
https://github.com/witsch/SublimePythonTidy
and while i "pip installed" the package in python, sublime would not load, throwing:
terminate called after throwing an instance of 'boost::python::error_already_set'
/usr/bin/subl: line 3: 12415 Aborted
/usr/lib/sublime-text-2/sublime_text --class=sublime-text-2 "$#"
How would I go about installing this without PackageController, or alternatively, can anyone recommend another package?
ctrl+shift+P then Package Control: Install Package
Look for Python PEP8 Autoformat and install it.
Try doing the following in command line (a bit brute force):
Navigate into the Packages/PythonTidy folder,
usually ~/.config/sublime-text-2/Packages/PythonTidy
or ~/.config/sublime-text-2/Packages/SublimePythonTidy
If it's non-existent reinstalling using Package Control
Inside there should be another PythonTidy folder (which in your case will be empty).
Don't get into it, just check it is empty.
Run git clone https://github.com/witsch/PythonTidy.git
Restart sublime and check the console for errors (View -> Show Console)
P.S.
If you are unable to start Sublime do a:
sudo pip uninstall PythonTidy
Then retry what I wrote above.
Package Control should create an appropriately named folder in Sublime Text's packages folder. You can get there from Preferences > Browse Packages. If the package installed correctly, there should be a folder called PythonTidy. If there's not, you can download the package from github directly and place the folder in this Packages folder.