I am trying to import the web module of python to create a simple Hello World program on my browser using web.py.
When I run it from the command line I am getting errors about the web.py package. If I run it from IDLE, it works fine.
Sometimes the problem is in the PYTHONPATH, and the IDE modify the environment variables so when you run it from there you don't have a problem.
Related
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".
I have two files - one PHP file and one Python file. The python file imports the Jira module, searches for issues, and obtains information from Jira. This file does function correctly and it will find Jira issues and return all needed fields successfully.
The PHP file (for this example, let's call it py_exec.php) is part of a website and executes the Python file through shell_exec; something to the effect of:
$jira_issues = shell_exec(python3 py_search.py issue=blah);
print_r($jira_issues);
When I run the Python script directly, the script works correctly.
When I execute the PHP script directly, which in turn executes the Python script, the script works correctly.
But when I run the PHP script from the website, the script returns nothing.
After troubleshooting a bit, I tried to run the command as the apache user and I am given the following error:
ModuleNotFoundError: No module named 'jira'
Obviously the module is installed, but it seems that it's not accessible to Apache.
How do I make this module accessible to Apache?
Many thanks, in advance, for any help I can get.
su to the apache user and run pip install jira. Check that it worked by doing python and then import jira.
Sometimes pip ends up aliased to something other than python. So if you have issues, try python -m pip instead.
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.
running the following on windows 10
C:\code\EPMD\Kodex-1.4.6\EPD_Prerequisite\Anaconda2\Scripts/py-spy.exe --nonblocking -- python C:\code\EPMD\Kodex-1.4.6\Applications\EPMD-Software\Preprocessor/Main.py
gives
import error, no module named <>
even though the script Main.py is running fine.
How do I make py-spy recognize imports?
This should just work. Can you create an issue on github?
As a work around, you can run the program yourself and get py-spy to profile it by passing the PID.
I have a script which works fine on the terminal. I'm trying to tie it to a jenkins job, which essentially only needs to run the python script. So I've written a little shell command at the bottom which calls the script.
However, when it runs, it throws the following error:
ImportError: No module named request
It's coming from this line:
import urllib.request
I've tried changing the shebang from python2.7 to python3, but then I get the same error but for the pkg_resources module, which sits right below the first one.
import urllib.request
from pkg_resources import parse_version
Seems like it should be an easy fix but it's not so far. Does anyone know what I need to do to get Jenkins to recognize these python modules? Again, no problems importing either of these modules on my Terminal.