I have installed pymindwave in the following directory:
C:\Python27\Lib\site-packages
However when I run another code which depends on it it says it can't find pymindwave. What's the solution?
Here's the first few lines of the code that gives the error:
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import platform
import sys, time
from pymindwave import headset
import httplib, urllib, urllib2
import json
And I have taken the code and python_mindwave from these links.
P.S.: I am not a Windows person but MindWave doesn't get recognized in OSX so I am forcefully using Windows 8.1 enterprise edition!
Try importing mindwave instead of pymindwave.
Related
I'm trying to use urllib (for backward compatibility), but I always get an error when running the script.
I tried installing urllib but got this error
ERROR: Could not find a version that satisfies the requirement urllib (from versions: none)
ERROR: No matching distribution found for urllib
Python version - 2.7.16
this is the import part in the script which fails:
from urllib import request, parse
from urllib import error as urllib_error
import error:
ImportError: cannot import name request
Please advise.
From the 2.7 documentation :
The urllib module has been split into parts and renamed in Python 3 to urllib.request, urllib.parse, and urllib.error.
So if you are trying to import urllib.request, parse and error separately - that constructs are available in Python 3.x version.
Please go through the documentation for 2.7 at : https://docs.python.org/2.7/library/urllib.html
Or upgrade to latest verion of Python 3.x to import the way you have described in your post.
You should import like this:
Download latest version of python from here
import urllib.request,urllib.parse, urllib.error
There is no urllib.request module in Python 2, that module only exists in Python 3, You can use urllib2 and Request:
from urllib2 import Request
The issue was that my environment was configured to use Python2 and not Python3, once I resolved this, the import worked as expected.
I am trying to run a program. It said in it's readme to install requirements first, so I did and it installed pyforms and python_docx
But now when I execute command
python
and i get the error ModuleNotFoundError: No module named 'pyforms.gui'
How can that be fixed?
I tried manually installing pyforms-gui and got message that I already have this module installed.
# -*- coding: utf-8 -*-
import pyforms
from pyforms.controls import ControlButton
from pyforms.gui.controls.ControlEmptyWidget import ControlEmptyWidget #problematic line
from pyforms.gui.controls.ControlProgress import ControlProgress
from generation import Project
from widgets.stage_13 import Stage13Window
from widgets.stage_5 import Stage5Window
from .initial_data_editor import InitialDataEditor
Your import statement is incorrect. The correct imports are given here. Note that pyform.gui is now pyforms_gui.
from pyforms_gui.controls.control_emptywidget import ControlEmptyWidget
from pyforms_gui.controls.control_progress import ControlProgress
I am a newbie with Python and I always run scripts with terminal. Now I would like to run and debug using PyCharm. I have this script:
# -*- coding: utf-8 -*-
matplotlib.use('Agg')
import sys
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import os
import math
import time
from time import sleep
import fpformat
sys.path.append("/Users/myname/OneDrive - UCL/my_folder/build")
from my_module_name import example
When I run the script with terminal everything works.
When I use PyCharm I have this:
/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 "/Users/myname/OneDrive - UCL/my_folder/Simulations/S16/03/04_Command_compacity/8.Compact_resistance.py"
Fatal Python error: PyThreadState_Get: no current thread
The problem is here:
sys.path.append("/Users/myname/OneDrive - UCL/my_folder/build")
from my_module_name import example
I have to use this module for my master thesis and if I remove these two lines I can run other scripts, but I can't run scripts that use this module.
Could you help me? Thank you!
I typed
which python
in terminal and I changed the directory in the Python Interpreter settings
I am using Raspberry PI 3 Model B running Kali Linux and i am currently coding a P2P encrypted python chat that runs on python 3. The cryptographic library i am using is called "CryptoShop", which is a '.py' file, not a imported library. I use it the same way that it's 'README' file instructed, so this is not a thing. Before i adeed crypto to the chat, it worked well, but now, i'm having errors since CryptoSHop uses the TQDM math library, and tryed installing it using APT-GET, PIP, by Source and nothing, because, firstly my chat only runs on Python3:
root#kali:~# python PyChat/pychat.py
File "PyChat/pychat.py", line 16
SyntaxError: Non-ASCII character '\xc3' in file PyChat/pychat.py on line 16, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
So when i use Python3:
root#kali:~# python3 PyChat/pychat.py
Traceback (most recent call last):
File "PyChat/pychat.py", line 4, in <module>
from cryptoshop import encryptstring
File "/root/PyChat/cryptoshop.py", line 52, in <module>
from tqdm import *
ModuleNotFoundError: No module named 'tqdm'
CryptoSHop try importing tqdm.
Here's a piece of it's code:
import os
import sys
from tqdm import *
import getpass
import argparse
I am still on the level of basic coding, i get this piece of chat code on the web, and just adeed to it basic user authentication (check if file whit the username exists), improved usability, and adeed crypto.
And sorry by my bad english, it's not my native language ;-)
Thanks in advance.
I am spanish, this happend when you use acents or special charts.
Add this in your first line:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
And use pip3 for install tqdm in python3
pip3 install tqdm
When I launch my CGI (common gateway interface) by using this code:
# -*- coding: utf-8 -*-
import cgi
import os
import json
import cgitb
cgitb.enable()
from sklearn.feature_extraction.text import CountVectorizer
print 'Content-type: text/html'
print
print '<html><head><title>Interface Ticket Recognition</title></head><body>'
formulaire = cgi.FieldStorage()
os.chdir("C:\Users\iyacine\Desktop")
path= os.getcwd()
from subprocess import call
call(["Python", "applicationV1.py"])
if path=="C:\Users\iyacine\Desktop":
print '''changer'''
print '</body></html>'
I got an error:
I try to change the path in environment variable but this work only in cmd.
I installed anaconda i my computer and i can run the module sklearn.feature_extraction.text in Spyder but not from Apache. Do you know how to solve this issue please?
You should have a first line like #! /usr/bin/python (called Shebang line) in your script. You have to change that line to point to the python executable you actually want. For Windows have a look at the docs but there also is the possibility to run ".bat" files via CGI so you could use a file (eg runmyscript.bat) containing just
#C:\path\to\anaconda\python.exe path\to\script.py
which is a hacky workaround (I think) but should work, too.
In my experience it is the best to use virtualenv if possible - this does not fix the path-problem directly but helps keeping different applications isolated.