I am a beginner and learning Python. I have setup the environment with SublimeText and Python3.x
I am fine in creating code on Sublime and building it locally through Ctrl+B and for input() function I installed SublimeREPL and it works find up till now.
The issue I am facing is on Python interpreter. I am facing below error while import any package:
import tweepy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tweepy'
I cannot even run a Python script from there. My Python path is below:
C:\Users\waqas.FVC\AppData\Local\Programs\Python\Python37-32
Demo.py and hello.py are the two scripts I wrote initially which I am trying to execute from Python Terminal, but it is showing below errors:
test.py
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'test' is not defined
Demo.py
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'Demo' is not defined
The initial Python download includes a number of libraries, but there are many, many more that must be downloaded and installed separately. Tweepy is among those libraries.
You can find, and download, tweepy from here:
https://pypi.org/project/tweepy/
Related
I made a library named converttxttoxml (https://pypi.org/project/converttxttoxml/0.0.2/) but everytime someone tries to run it a error of module not found pops up after successful installation of library.
import converttxttoxml
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'converttxttoxml'
But running totally fine in my pc.
I'm using PyCharm for a project with the following file hierarchy:
And I'm running main.py in PyCharm with the following configurations:
Working Directory: /Users/me/longpath/project/amlproject/pca_mixtures.
When I try to run in terminal, it fails:
~/longpath/project/amlproject/pca_mixtures$ python main.py
Traceback (most recent call last):
File "main.py", line 2, in <module>
from pca_mixtures.funcs import PCAMixture
ModuleNotFoundError: No module named 'pca_mixtures'
and nothing changes if I jump up to the parent folder:
~/longpath/project/amlproject$ python pca_mixtures/main.py
Traceback (most recent call last):
File "pca_mixtures/main.py", line 2, in <module>
from pca_mixtures.funcs import PCAMixture
ModuleNotFoundError: No module named 'pca_mixtures'
The reason for using from pca_mixtures.funcs import PCAMixture instead of just from funcs import PCAMixture was so that PyCharm would recognize the import and not red-underline it, as I've described here. Now, it seems that this has lead to me not being able to run the project in the terminal.
How would you handle this? I want to be able to run it in the terminal because the PyCharm output is not fully sequential (error messages output before program output) which is annoying when debugging.
I got this message at XCode after deleting some system files.
(lldb) script
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'run_python_interpreter' is not defined
P.S. Had to reinstall XCode, but I've got same message at debugger after reinstalling IDE
Terminal output
$ lldb
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 52, in <module>
import weakref
File "/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
You have a local installation of python on your computer (in /usr/local/Cellar). There's a problem when you have two different pythons on your system; lldb links against /System/Library/Frameworks/Python.framework but that python somehow ends up using the python libraries from your installed copy instead. I saw someone work around this once but I forget if it was by putting their local python last in $PATH or if they un-set their $PYTHONPATH before starting lldb.
I am running python 2.7 and matlab2015a from a virtual environment. Both matlab and python are properly in the path (I can start them from terminal). But, whenever I do this:
python
from matlab.engine import pythonengine
pythonengine.find_matlab()
I get this:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'find_matlab'
I get similar errors for all other functions in __init__.py in my /lib/python2.7/site-packages/matlab/engine.
I have installed the pythonengine using the instructions in https://www.mathworks.com/help/matlab/matlab_external/install-the-matlab-engine-for-python.html from my virtualenvironment.
This is because find_matlab() is a function of matlab.engine, not matlab.engine.pythonengine. Try:
python
import matlab.engine
matlab.engine.find_matlab()
I'm having issues running ortools on Linux. I downloaded it from google's site (https://developers.google.com/optimization/) and installed it using "make install," but when I go to use it in python I get the following:
Traceback (most recent call last):
File "regular.py", line 42, in <module>
from ortools.constraint_solver import pywrapcp
File "/home/m3/summer/ortools_examples/examples/python/ortools.py", line 2, in <module>
ImportError: No module named linear_solver
It looks like despite installing ortools, its still not in my python path correctly, so when I call it in the file, it doesn't find anything and returns an error, right? Any advice on how to solve this?