I am trying to install the IpythonIntegration package in sublime,
I installed in a bash shell:
the latest ipython
pyzmq
pyside
However, the sublime console still gives me an error of
Reloading plugin /home/areal/.config/sublime-text-2/Packages/User/ipython_repl.py
Traceback (most recent call last):
File "./sublime_plugin.py", line 62, in reload_plugin
File "./ipython_repl.py", line 13, in <module>
from IPython.zmq.blockingkernelmanager import BlockingKernelManager
ImportError: No module named IPython.zmq.blockingkernelmanager
EDIT:
Even a import IPython won't work.
When in python console, import IPython and import zmq work, however:
from IPython.zmq.blockingkernelmanager import BlockingKernelManager
Fails with:
ImportError: No module named zmq.blockingkernelmanager
I have 0MQ 3.2 (also tried with 2.x), and latest PyZMQ.
I am working with Python 2.7.2 on Ubuntu 11.10.
So in general I have 2 problems:
No IPython in Sublime (I assume it is because sublime works with an embedded interpreter)
No zmq module in IPython
I am not using Ubuntu, but I meet similar issue in Mac OS X.
The reason why it success in standalone python and fail in sublime text 2 is : sublime text 2 is using python 2.6 defaultly, while you standalone python is 2.7.
To solve this, in my OS X, I create a soft link from 2.7 to 2.6, something like below:
cd /Library/Frameworks/Python.framework/Versions/
sudo mv 2.6 2.6-backup
ln -s 2.7 2.6
I think you can do same thing in Ubuntu.
Related
I am trying to make a nmap scanner for the InfoSec Certification on freeCodeCamp.org and cannot get Visual Studio Code to recognize that I have installed nmap. I am very beginner and in the process of learning.
from cProfile import run
import nmap
scanner = nmap.PortScanner()
print("Welcome, this is a simple automattion tool")
print("<------------------------------------------->")
When I run this in VS Code I get the following in the terminal:
PS C:\Users\mjame\OneDrive\Documents\Jim\Coding\fcc_python_for-pen_testing\nmap_scanner_1> python3 scanner.py
Traceback (most recent call last):
File "C:\Users\mjame\OneDrive\Documents\Jim\Coding\fcc_python_for-pen_testing\nmap_scanner_1\scanner.py", line 2, in <module>
import nmap
ModuleNotFoundError: No module named 'nmap'
PS C:\Users\mjame\OneDrive\Documents\Jim\Coding\fcc_python_for-pen_testing\nmap_scanner_1>
I have so far:
Updated to the current Python 3.10.7
Installed Nmap the first time from https://nmap.org/ for Windows
Uninstalled Nmap
Reinsalled Nmap using >>>pip3 install python-nmap
For future searchers (as in my comment above), if you installed a module with pip3 but are still getting module import errors, try python3 -m pip install <module-name>.
Not sure how/why this happens (pip3 installing somewhere that python3 is not looking for modules - maybe PYTHONPATH-related), but the above can [usually] help.
It seems that Python cannot find nmap module.
You can either add it to path in Windows via Start -> Edit system environment variables -> Environment variables... and then edit PATH VARIABLE by adding at the end path to nmap module that you have installed or move the module to default Python modules directory which should be C:\Users\YourLogin\AppData\Local\Programs\Python\Python310\Lib\site-packages
Mac OS VSCode built-in terminal can't import installed python packages.
I've installed NumPy correctly using Anaconda in one of my environments called tf20;
And then I created a python script scene.py
import numpy as np
print(np.__version__)
I can run this script in my system Terminal like:
(tf20) mac#Macbook:~/Desktop/manim_project$ python scene.py
1.18.5
However, an import error occurred when I run the same script.
(tf20) mac#Macbook:~/Desktop/manim_project$ python scene.py
Traceback (most recent call last):
File "scene.py", line 10, in <module>
import numpy as np
ImportError: No module named numpy
However, when I run this by pressing F5, the debug mode, the problem disappeared.
(tf20) mac#Macbook:~/Desktop/manim_project$ cd /Users/mac/Desktop/manim_project ; /usr/bin/env /Users/mac/.jackprogram/anaconda3/envs/tf20/bin/python /Users/mac/.vscode/extensions/ms-python.python-2021.11.1422169775/pythonFiles/lib/python/debugpy/launcher 62372 -- /Users/mac/Desktop/manim_project/scene.py
1.18.5
(tf20) mac#Macbook:~/Desktop/manim_project$
I think I selected the right python environment tf20 in VSCode because
the VSCode built-in terminal showed (tf20) at the beginning of the terminal prompt.
the left corner of VSCode showed Python3.7.7 64-bit ('tf20:conda').
and I even used cmd + shift + p then Python: Select Intereter to ensure I selected the right python environment.
Because of this problem, I have to use the macOS terminal application to run the Python scripts for a half year.
Help. Please!
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.
I am using python3.
I installed twython on my MAC using pip3 command and I confirmed it was successfully installed.
When I run my python file, it comes up with:
ImportError : No module named twython
My code is as follows:
import sys
import string
import json as simplejson
from twython import Twython
I can't comment the response from #ajxs, but as additional information to his repsonse:
You can change the default python interpreter like this in your MAC terminal:
nano ~/.bash_profile
Add this to the file:
alias python=python3
exit the the bashrc file and run the following command:
source ~/.bash_profile
Now you can check the defaul python version with:
python --version
Maybe this helps you.
First thing that springs to mind is to check that you're running the script with the correct version of Python. Use python --version on the command line to check which version of Python you're executing by default. I've definitely had problems like this before when I've forgotten that my system's default version was 2.7 and I needed to use python3 to run Python 3 on the command line.
I'm trying to convert a CVS repository to Git using cvs2svn and am following the directions on this page. I got to step 7 but am getting an error running git-move-refs.py:
Traceback (most recent call last):
File "../../cvs2svn-trunk/contrib/git-move-refs.py", line 23, in ?
from subprocess import Popen, PIPE, call
ImportError: No module named subprocess
For reference, this is what the script shows:
usage = 'USAGE: %prog [options]'
import sys
import optparse
from subprocess import Popen, PIPE, call
I'm not a Python expert but from browsing the web it looks like subprocess is a standard module, right? I'm using a Python installation built from source for version 2.6.3. What am I missing for this script to work?
I'm guessing that you have an old version (pre-2.4) of Python at /usr/bin/python, from your distribution, and the Python 2.6 you compiled is somewhere else (like /usr/local/bin/python). You have the Python 2.6 executable on your path before /usr/bin, so when you execute python from the command-line you get Python 2.6.
However, looking at the cvs2svn source code, git-move-refs.py's interpreter line is hard-coded to
#!/usr/bin/python
instead of #!/usr/bin/env python, which means when you run the script it uses the old Python.
As a workaround, run the script by passing it to your Python 2.6 interpreter:
user#host$ python /path/to/cvs2svn/contrib/git-move-refs.py