I'm using a script to run Odoo11 via pycharm in ubuntu (openerp_openserver script)
When i try to run the program , it fails at some point , when it import pdf module and i have this error :
ImportError No Module Named 'PyPDF2' as you can see in this Image
I Already installed PyPDF2 via this command (i have python3.5 already installed) :
sudo apt-get install python3-pypdf2
So im wondering , what is the problem , why pycharm cannot find and import pypdf2?
Thanks
EDIT :
When i Try to import PyPDF2 using the Python command , i dont have error
Firstly you should try to check whether you can import PyPDF2 library from a python console.
Run from your native console:
python3 -c "import PyPDF2"
If no error message occurs, the problem is not in the library.
Check a path of python interpreter that is used by PyCharm.
Navigate inside PyCharm:
Ctrl-Alt-S > Build, Execution Deployment > Console > Python Console
The path should be to /usr/bin/folder.
If not - change it to a path of the desirable python interpreter that is inside /usr/bin/ folder.
I hope this helps!
Will be good if someone can add a way to solve this type of problem in Windows environment.
For windows you may try installing psycopg2 and requirements again for venv(virtualenvironment.
For psycopg2 install you should follow the steps under "Virtual Environment Installation Notes" title on http://www.stickpeople.com/projects/python/win-psycopg/
Related
I want to run a python script with the cherrypy module. I use pip install cherrypy to install it and all looks ok. Then I click the "Run python file" button and I face the error ModuleNotFoundError: No module named 'cherrypy'.
Trying to reinstall cherrypy I see many Requirement already satisfied responses.
If it helps I have already edit, in the user path variables panel, the Path variable and added C:\Users\username\AppData\Local\Programs\Python\Python37-32\Scripts as a path.
edit: I suspect some problem with the path. So i run the following.
>>> import os
>>> import sys
>>> os.path.dirname(sys.executable)
'C:\\Python25'
it returns: 'C:\\Users\\username\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0'
Have you tried to install cherrypy using C:\Users\username\AppData\Local\Programs\Python\Python37-32\Scripts\pip install cherrypy
When I install py libraries I always run where python and find the right python copy it and modify the path so it goes in Scripts then run pip install cherrypy
Also I noticed that when I install py libraries it seems VSCode won't recognize it even though it runs. To fix this you have to restart VSCode again
Another possibility is that your VSCode isn't using correct version of Python. To check this look at VSCode bottom left you should see your python version. If VSCode can't recognize it you will have to enter the Python path manually by Open Command Palette Ctrl+Shift+P and choose Python: Select Interpreter then click enter Interpreter path
So I am trying to install and import pynput in VSCode but its showing me an error every time I try to do it. I used VSCode's in-built terminal to install it using pip and typed the following :
pip install pynput but this error is shown : Fatal error in launcher: Unable to create process using '"c:\users\vicks\appdata\local\programs\python\python38-32\python.exe" "C:\Users\vicks\AppData\Local\Programs\Python\Python38-32\Scripts\pip.exe" install pynput': The system cannot find the file specified
After receiving the following error, I tried using CMD to install it but the same error is shown. I also tried using python pip install pynput and it shows Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases. even though I have python 3.9.7 and I have selected it as my interpreter in VSCode and I have IDLE(Python 64 bit) installed. How may I resolve the following error? Any help regarding the same is appreciated
Thanks in advance :)
There's no such thing as an in-built terminal in VS code. When you open a terminal in VS Code, it opens the default, which on Windows is usually equivalent to opening up CMD.
If you selected Python 3.9.7 as your default interpreter in VS Code, it does not mean that it will visible to your CMD / terminal. It just means that the VS Code IDE will refer to that instance of Python when launching the program from VS Code itself using the green button (or F5), and when scanning your code to point out missing packages, etc.
CMD will only automatically detect your Python if it's in your PATH environment variable. You should add the Python 3.9.7 base and Scripts path to this.
Also, it would be best if you could first uninstall conflicting versions (like your 3.8.x) of Python and remove them from PATH, assuming that this won't cause any problems for you. Perhaps keep a record all the installed packages in this old version of Python for future reference using pip freeze or pip list.
Check if c:\users\vicks\appdata\local\programs\python\python38-32\python.exe exists by typing cd c:\users\vicks\appdata\local\programs\python\python38-32
I'm trying to import selenium from a python3 application. I've already installed it asi you can see in the first image.
I also configured the vs code with python3 (image 2).
Both if i try to run it from vs code console or with python3 it says the same error.
Exception has occurred: ModuleNotFoundError
No module named 'selenium'
File "/Users/admin/Documents/Bot/bot.py", line 1, in
from selenium import webdriver
I've tried several answers from StackOverflow but it didn't seem to work with me.
Note: i'm not using a virtual environment.
Since apparently i have a lot of python3 installed on my system i just created a virtual environment.
go to your program folder and type:
python3 -m venv virtual-env
this will create a copy of python3 inside your program folder (in /virtual-env/bin/)
then you need to activate it:
source /virtual-env/bin/activate
this will activate your virtual environment, so you can use your own copy of python3 located on your folder.
Once activated, your console will look like this:
(virtual-env) user:program admin$
thanks to everyone and sorry for the lateness
I have tried to put this script in the sitecustomize.py file, to be able to see colored error messages in visual studio code.
the script:
import sys
from IPython.core.ultratb import ColorTB
sys.excepthook = ColorTB()
I got the error message above even though I have used pip to install ipython.
EDIT:
I tried to use coloredlogs instead of ipython and it showed me the same message again
The IPython module only works inside iPython, not inside any other IDE/Shell/etc.
Please use the command "pip show ipython" to check the installation location of the module:
(If it does not display the location of the module, it means that the terminal used environment is inconsistent with the selected one.)
Then find the folder of the module in this python environment, try to delete it, and then reinstall it:
Run:
I needed to reinstall python on my computer. there were multiple versions of it, and because of that there were multiple versions of pip
I have installed sqlalchemy in my pathon. Im running python 2.7.15
When I execute my test program it says;
ImportError: No module named sqlalchemy.util._collections
I have installed modules with my python version.
Flask-SQLAlchemy 2.3.2
SQLAlchemy 1.2.2
WHy do I get this error in pycharm. PyCharm run configurations picks correct python version.
In console i tried the import statement it works.
$ python --version
Python 2.7.15
>>> from sqlalchemy.util import _collections
>>>
Why I get this error in pycharm?
First thing I would check is that you're using the correct Python environment in PyCharm.
Use the which python function in your console to see the path to the python executing in your terminal and make sure that it lines up with the path under "External Libraries" in your project view. You may not have sqlalchemy installed on the Python executable in your Pycharm Project. I've had similar issues in the past where I had Python installed alongside Anaconda.
Also consider dropping a requirements.txt file into the root level of your project in Pycharm. If your Python environment doesn't have the library installed it will generally prompt you to install it. Just add in a single line into your requirements.txt file with sqlalchemy. Using echo you could create this file using the following command
echo "sqlalchemy" >> requirements.txt
This is due to Pywren [1] library which could not import some 3 rd party libraries. Not a Python/PyCharm issue
[1]https://github.com/pywren
[2]https://github.com/pywren/pywren/issues/253