Running Python script in Linux, fail with pyperclip import - python

Good day everyone.
I'm the beginner in learning Python. I made script with import of pyperclip module. When I run this script in Spyder IDE, everything is OK. When I start this script from terminal, it is also OK.
But when I'm trying to make .desktop file to run this script from dash menu,then terminal returns me the error "pyperclip module not found". I can't understand this, because I've installed this pyperclip module successfully and I can use it in IDE.
I'm using Linux Mint 20, if it is important.
Trying to run Python script with pyperclip module using .desktop file in Linux Mint.
This script works normally in IDE and from terminal
I expected that it it would be working normally if I started this from .desktop file.
But it gives me error "pyperclip module not found".

Related

VS Code integrated terminal shows Qt incompatibility when matplotlib script is run

Every time I tried to run a Python script containing matplotlib in VSCode, I receive the following message in the integrated terminal:
Cannot mix incompatible Qt library (5.14.1) with this library (5.15.2)
Runing script from VSCode:
If I run the script directy from the terminal outside VSCode, the script is running fine.
Runing script from terminal:
Any idea how to fix this?
Have you installed PyQt5 packages? If it is, could you try to uninstall or reinstall it?

Can't run Python scripts in Sublime on Mac OS

Just to get it out of the way, I'm new at Python and coding in general, but very eager to learn how to do it.
The problem is that I can't run Python scripts through Sublime Text. I'm using Mac OS 10.15.7, and I've downloaded the latest version of Python from the official website and then also with Anaconda.
When I try to run any Python script in Sublime, I get the following message:
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: can't find '__main__' module in ''
[Finished in 0.3s with exit code 1]
[shell_cmd: python -u ""]
[dir: /private/var/folders/wh/lt9wn7qn7zl4p8xkj67bhpyh0000gn/T/AppTranslocation/86FABCDF-E2DC-4C15-A564-EFE9529B919B/d/Sublime Text.app/Contents/MacOS]
[path: /Users/alexherranz/opt/anaconda3/bin:/Users/alexherranz/opt/anaconda3/condabin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]
I looked at some other similar questions here, and I installed the SublimeREPL package as many recommended, but I'm probably missing something, as I still get this error message. It's quite frustrating, as I'd like to run the scripts within Sublime instead of copying it everytime to the terminal.
Is there a fix for the problem I'm running in to? Any ideas appreciated!
You've entered code in the editor, but you haven't saved it as a .py file. Save the file, hit ⌘B, and it should run just fine.
Make sure you save the file first, before attempting to run it.
If you "save as" the file somewhere on your computer you should be able to then go into the mac version of the file explorer and then double click your file. If it is a file that opens a window, like tkinter or turtle it will run the code normally. If not it should run the code in the mac version of the command prompt. Make sure it is opening the file with python.

ImportError: DLL load failed while importing _imaging: The specified module could not be found

I'm trying to run my python script that I developed/tested through IDE and it's working fine over there.
But when I try to run the same script on Command Prompt (Windows 10) which has to import any module. Note that python script and the .bat file is in the same directory.
I think this is happening environment setup so I did some search and found these posts below;
import error: 'No module named' *does* exist
No module error when running python script from command prompt
Python command line Import Error
Unable to imoprt modules on python script while running on cmd
Package doesn't work if run from cmd or from the .py file.... PYTHON
https://www.programmersought.com/article/7436148385/
Here is the error snapshot
Steps followed
Python version 3.8.3
Environment variables are set under system environment variables
in the 'code.py' also added
import sys
sys.path.append('D:\program_files\anaconda3\Lib\site-packages')
Seaborn and Scipy updated the latest versions
CMD FILE look like this
I followed older solutions like set up environment variables for python libraries and python path so for not even close to get rid of this error.
Any idea to help what I'm missing here ?
Thanks

PyCharm Run Doesn't Recognize Packages But Console and Terminal Are OK

Running PyCharm 2020.1.2 Community Edition in Win10 with a Python 3.6 venv as interpreter. Installed the package feature-engine through the Project Interpret interface, installs fine and appears in the list. I can successfully import feature_engine in the PyCharm console, and I can use it fine. I can also execute a .py file with this import statement in the Terminal with the venv activated, and it also works fine. However, when I try to Run the same .py file with the import statement, I get:
ModuleNotFoundError: No module named 'feature_engine'
I have tried using import and importlib, thinking the issue was the hyphen, but those didn't work. I have tried uninstalling and reinstalling, restarting PyCharm, etc. Nothing seems to work. Any suggestions how to get the Run function working?
EDIT: Thanks for the suggestions. Attached are the Run configuration and the Project interpreter configuration. As far as I can tell, the environment is the same.
Below are examples of the error trace. The object being Run is a Flask app, which imports packages that use the feature-engine library. The actual import statement in the final import is simply import feature_engine. Trying to import the method directly using from feature_engine import variable_transformers as vt also fails.
Make sure you're using the right configuration to build your program (that is, using the python executable of the right enviroment). You can check this in the top right corner, where the run button is.

Selenium doesn't load in Jupyter, but works in Python3 in console and Sublime Text

I'm trying to load selenium in a Jupyter Notebook running Python 3. When I try to import Selenium I get a "ModuleNotFoundError: No module named 'selenium'" error. This doesn't happen when I run the same command from Python 3 in the Terminal or using Sublime Text.
I've tried a number of fixes, but can't seem to find a solution.
It turns out that Jupyter was running a different version of Python3 than my terminal. I found the discrepancy using which python3 in the terminal and
import sys
sys.executable
I then specified pip3 from the path given by the latter command and voila, it worked!

Categories

Resources