I installed python 3.8.8 and installed wxpython using pip at terminal
pip install wxpython
and i run simple program
import wx
print(wx.version())
in pycharm and pycharm`s python console, I got
ModuleNotFoundError: No module named 'wx'
in IDLE, I got
Traceback (most recent call last):
File "C:/Users/tasoo/OneDrive/Desktop/wx.py", line 1, in <module>
import wx
File "C:/Users/tasoo/OneDrive/Desktop\wx.py", line 2, in <module>
print(wx.version())
AttributeError: partially initialized module 'wx' has no attribute 'version' (most likely due to a circular import)
in python.exe code works
I want to import wx in pycharm project.
I tried add python in system path but it didn`t work.
You have problem because you saved code in file wx.py and now import wx loads your file wx.py instead of module wx. Rename your file - ie. main.py instead of wx.py
PyCharm may have own Python installed and it may need to install wx in this Python.
Check
import sys
print(sys.executable)
to get full path to Python used by PyCharm and then use this path
/full/path/to/python -m pip install wx
Or search in PyCharm settings (in menu File) and change Python Interpreter.
In PyCharm for every project you may set different Python - if you have installed many versions.
Related
First of all the project structure looks like this
-- ba-amin-code (main directory)
-- Diverse
-- LanguageIdentification.py
-- TextAlignment
-- FileHandler.py
-- TextHandler.py
I want to import a python file from TextAlignment when im in Diverse.
Project Structure, import statements
This is how I imported it, but im getting this error when running it like this
enter image description here
Is this way wrong to import?
Update:
This is how im importing two py files from TextAlignment.
Im in LanguageIdentification.py
import fasttext
import urllib
import typer
from TextAlignment import TextHandler
from TextAlignment import FileHandler
After that im running the program`from the root-directory (ba-amin-code) by console with this command
python Diverse/LanguageIdentification.py "INPUT.txt"
getting this error
Traceback (most recent call last):
File "C:\Users\Snur\Pycharm Projects\Gitlab\ba-amin-code\Diverse\LanguageIdentification.py", line 4, in <module>
from TextAlignment import TextHandler
ModuleNotFoundError: No module named 'TextAlignment'
The package might be installed in a different venv. Did you try running your code from the pycharm console, with your venv activated?
You have two yellow warnings in pycharm at your imports: what are they?
Otherwise, try the command: $pip list to see if the package is correctly installed in your venv.
When i attempt to import selenium i get the error:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import selenium
ModuleNotFoundError: No module named 'selenium'
My selenium module is currently in:
C:\Users\Maseeek\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\selenium
I've seen other people have it in a different directory and want to know how to fix it.
If you are using "PYCHARM" and if you created project with "Virtual Environment" you should choose "Python 3.x.x" instead of "Virtual Environment Python 3.9" that PyCharm created.
If you installed "anaconda" before you need to change paths of libaries.
If you're using PyCharm, then this might help:
PyCharm sometimes shows an error in importing modules that have already been installed (that's annoying). But, try to change the file location to this destination:
C:\Users\Maseeek\PyCharm Projects\(project name)\venv\site-packages\
or try installing the package in PyCharm using python with the following code:
from sys import *
from subprocess import *
call(["-m", "pip", "install", "selenium"])
I need help with the pyodbc Python module. I installed it via Canopy package management, but when I try to import it, I get an error (no module named pyodbc). Why?
Here's the output from my Python interpreter:
import pyodbc
Traceback (most recent call last):
File "", line 1, in
import pyodbc
ImportError: No module named 'pyodbc
For the record: the attempted import was in a different Python installation. It is never good, and usually impossible, to use a package which was installed into one Python installation, in another Python installation.
When I try to import the slycot module in spyder (version 2.2), I get the following error:
RuntimeError: module compiled against API version 7 but this version of numpy is 6
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Applications/Spyder.app/Contents/Resources/lib/python2.7/slycot/__init__.py",
line 4, in <module>
from slycot.analysis import ab01nd,ab05md,ab05nd,ab07nd,ab08nd, ab09ad
File "/Applications/Spyder.app/Contents/Resources/lib/python2.7/slycot/analysis.py",
line 21, in <module>
from slycot import _wrapper
ImportError: numpy.core.multiarray failed to import
Now, when I import slycot in the python shell through my terminal, there are no problems at all. I think the reason why there are no problems through the terminal, is that I recently installed numpy 1.7.1. Spyder on the other hand still uses numpy 1.6.2.,hence the error.
I tried to change the numpy version in spyder, but so far that didn't work.
When I change the numpy(6) folder in my spyder lib with the recently installed numpy(7), I get the following error (in spyder):
ImportError: Error importing numpy: you should not try to import numpy from
its source directory; please exit the numpy source tree, and relaunch
your python intepreter from there.
What is the best way to solve this error?
Thanks in advance.
(Spyder dev here) At the moment it's not possible for the user to install anything inside the app. I guess you moved your slycot module from another interpreter to our App (because of the numpy error you mention).
The right way to use different modules not present in the app, is to change the path of your interpreter in:
Tools > Preferences > Console > Advanced settings > Python executable
If you installed slycot using your system Python, you have to select
/usr/bin/python
I am trying to import pythoncom, but it gives me this error: Traceback (most recent call last):
File "F:/Documents and Settings/Emery/Desktop/Python 27/Try", line 2, in
import pythoncom
File "F:\Python27\lib\site-packages\pythoncom.py", line 2, in
import pywintypes
ImportError: No module named pywintypes
I reinstalled Python win32, but it still doesn't fix it. Any help? Also, I am trying to access the pythoncom.PumpMessages() method, an alternative would be nice as well.
If you are using an IDE like I am (PyCharm), you should go the where the Python is installed e.g C:\Users\***\AppData\Local\Programs\Python\Python37\Lib\site-packages
In this folder check for the folder name pywin32. Copy that folder and paste it to C:\Users\***\PycharmProjects\project\venv\Lib\site-packages. After that restart your IDE, then it will import the pywin32 as it did in my case. I hope it helps.
pip install --upgrade pywin32==228