Problems with pywikibot in PyCharm - python

Henlo everyone,
I met a very specific problem with my Python installation. I have a PyCharm project using a venv with pywikibot installed. Whenever I try to import the module, I get the following error:
Traceback (most recent call last):
File "C:/Users/<username>/<path to project>/alphabets/coptic_characters.py", line 1, in <module>
import pywikibot as pwb
File "C:\Users\<username>\<path to project>\venv\lib\site-packages\pywikibot\__init__.py", line 15, in <module>
from decimal import Decimal
File "C:\Users\<username>\Anaconda3\lib\decimal.py", line 3, in <module>
from _decimal import *
AttributeError: module 'numbers' has no attribute 'Number'
It appears to have broken itself because earlier in the day it worked with no problems.
I also have the module installed on a global Anaconda3 setup elsewhere in my computer. It works fine everywhere except, that's where it gets weird, when I try to execute it inside the project directory. It gets even stranger than that, if I execute the interpreter in a sub-folder, it works again. I don't understand what's happening here at all…
I tried creating a new project but I get the same error and behavior.
What am I missing? I don't understand why it stopped working suddenly event though I did nothing to the venv.
P.S.: I'm on Windows 10.

So !
It appears that a module I created with the name numbers was interfering with Python's code. I just changed the name and it suddenly worked again !
Thanks to #furas for suggesting this.

Related

Why is Atom only allowing me to use the standard python library

I have recently changed my text editor from IDLE to Atom but when I started to run my program that i have ran in the past eg(music player using pygame) it didn't work and came up with this error message:
Traceback (most recent call last):
File "/Users/jacquelinethompson/Desktop/Untitled.py", line 1, in <module>
import pygame
ImportError: No module named pygame
[Finished in 0.088s]
I checked the import to see if it worked in IDLE and it works fine there. Can anyone explain why and how to fix it.
I am on the MacOS and am using python3.6

Can't Open File in Pycharm using Openpyxl

I'm trying to open an Excel file using Pycharm, but always get a the following message:
Traceback (most recent call last):
File "C:/Users/.../PycharmProjects/Excelmodules/openxlsx.py", line 2, in <module>
from openpyxl import openpyxl
ImportError: cannot import name 'openpyxl' from 'openpyxl' (C:\Users\...\PycharmProjects\Excelmodules\venv\lib\site-packages\openpyxl\__init__.py)`
Process finished with exit code 1
I have successfully installed Openpyxl in Pycharm (using another thread on stackoverflow) and have checked the file name/path is correct, but still get the error message.
I am new to python so it might be something I have/haven't done, but the only things I can think are causing this are:
running it through Pycharm rather than command prompt
Windows 10 did a forced update and created an "old windows folder and I'm wondering whether Pycharm or openpyxl are trying use/run using the old.windows folder
the Excel file needs to be in the Pycharm folder
I was starting a project in Automate the Boring stuff, but can't get past this step.
Please help!
Thank you
Rob

Python code get error in eclipse while it runs fine in terminal

I tried to run sklearn example, when I try to run it via terminal everything works fine but when I copy and paste this code in eclipse and try to run it I get this error:
Traceback (most recent call last): File "/Users/ABC/Documents/Eclipse/workspace/project/src/sklearn/plot_ROC.py", line 9, in <module>
from sklearn import svm, datasets ImportError: cannot import name svm
I check that both eclipse and system using the same version of python (at least I think so)
In terminal when I typed "which python" the result is "//anaconda/bin/python"
And in eclipse I set the same for Python interpreter as you can see in below picture.
So can anyone guide me what is the problem?
you may compare Python path under Eclipse and terminal by
import sys
print ( sys.path )
the order of entries does matter. My guess is that the fact that your Python file is in a folder called sklearn ( i.e .../project/src/sklearn) is messing the import statement.
requested edit: as it turned out, the problem was that the Python script was in a folder called sklearn and Python would look into that folder to import svm.

idle-python3.2 not starting: complains of NameError: name 'Tk' is not defined

running linux mint 13
idle-python3.2 did work from the terminal before, now it does not.
Calling idle-python3.2 from the terminal throws the error below BUT I can run Idle by double clicking on the script!
Here's the very simple script that broke it all(?)
http://pastebin.com/pP9An3UU
FWIW, the script does not appear to work either (nothing happens when I run it).
Here's the error in the terminal when trying to run Idle3.2 from the terminal:
File "tkinter.py", line 2, in <module>
tk = Tk()
NameError: name 'Tk' is not defined
here's the full error
http://pastebin.com/J5AfAQyV
I know tkinter is not installed by default... but it IS installed
python3-tk is already the newest version.
python3-tk set to manually installed.
I've checked the system monitor and killed all obvious python instances running in the background.
But, still no joy.
Here's a video of the error:
http://youtu.be/oCLOJR2rktI
Your help for a fix is appreciated.
It sounds like you either a) named your little test program "tkinter.py", or b) you have another file in the same directory named "tkinter.py". If that is the case, when you do from tkinter import *, you are not importing the real tkinter but rather importing the local file.
If you named your file "tkinter.py", rename it. Also, if there is a file named "tkinter.pyc", remove it.

Python ImportError with Sage

Okay I am newer to python and have been researching this problem but I can't find anything like it so I am not sure what is going on.
I am creating a program that involves sage and it has a message cue. We have this set up on a development machine, so I know it works but I was wanting to set it up on my own computer so I could get a better understanding of how it all works and make it easier to develop for myself.
To start up sage, we run a script that calls sages main binary file and passes it an executable .py file. (./sage/sage ./sage_server.py) This creates an error in the sage_server.py file:
Traceback (most recent call last):
File "./sage_server.py", line 23, in <module>
from carrot.messaging import Publisher
ImportError: No module named carrot.messaging
But whenever I run that file just in the terminal (./sage_server) the import works fine and isn't until line 27 that there is an error when it tries to import something from sage.
Does anyone know what would cause the error when it is being called by something else? I am very lost as to what would be causing this.
Sage has its own python, separate from the system libraries. This "carrot" module, whatever it is, must be installed in whatever python ./sage_server.py uses, but not in Sage.
You should be able to use either
[your-sage] -sh
to start up a Sage shell and use easy_install, or you could get whatever carroty package you're using, find its setup.py file, and then run
[your-sage] -python setup.py install
where obviously your-sage is the path to your sage.
Things get a little trickier if the install process isn't setup.py-based.

Categories

Resources