getting started with Enthought Canopy - pandas not importing? - python

I'm just trying to get started with python following Python for Data Analysis but I've been having a really tough time getting everything to line up (this is sad but I am four hours in at least to an attempted install...?!?!). I have an academic license for Enthought Canopy, and I read through this and tried to follow it:
http://docs.enthought.com/canopy/quick-start/install_windows.html
Problem is that the program never actually asked me to do an Environment Setup, unlike what the docs say. I tried rebooting, restarting the program, and uninstalling/reinstalling several times with no luck. All I want to do is play around with pandas, but package loading is clealy not working.
I am just trying to run this code:
import pandas
plot(arrange(10))
When I run this, here's my error:
import pandas
plot(arrange(10))
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-10-f4ad02ce74fb> in <module>()
----> 1 plot(arrange(10))
NameError: name 'arrange' is not defined
I am guessing this is somewhat related to some path or environmental variable that should have gotten set, but I'm completely lost to be honest.
Also I found the /Canopy folder in my /User folder. It has two subfolders, licenses and scripts, and both of these folders are completely empty even when I want to see hidden files.
Anyhow, if anyone has any advice or helpful links I'd really appreciate it. All I want to do is start messing around with python, and I've got no ideas how to get to that seemingly basic point. Thanks in advance.

I met with the same problem.
You can go to add c:\Python27;c:\Python27\Scripts to your environment variables under system properties of your computer
And it works

Related

Import module failed even though installed

i have a couple of different questions regarding importing modules and another non-related syntax question.
So, i'm using a module called netmiko to automate networking scripts, this isn't a networking question but a python one, i create the scripts in Pycharm and then run them but when i tried to do one last night for the first time using Netmiko it's coming up with an import module failed exception which is confusing me because i've installed it using "pip install netmiko" and i saw it install AND if i do "import netmiko" using the command line on Windows then it works as well with no exceptions. So i've been building the scripts in Pycharm but having to copy/paste them into then cli which isn't great. Does anybody know what the issue may be here?
The second question is just a general syntax question. I've seen "+=" used when using the same variable names in Python (mainly used in netmiko scripts but i assume it's obviously used in other Python scripts to) such as:
output = net_connect.send_command(cmd, expect_string=r'Destination filename')
output += net_connect.send_command('\n', expect_string=r'#')
....the rest of the script isn't import, but i'm wondering what the "+=" is actually doing here because to me it seems no different than doing:
output = net_connect.send_command(cmd, expect_string=r'Destination filename')
output = net_connect.send_command('\n', expect_string=r'#')
Can anyone shed some light on this as well?
Thanks as usual everyone!!

PyScripter: Why might some modules import personal modules while others dnot?

I am using PyScripter to implement a lesson from the Python Tutorial: https://docs.python.org/3.7/tutorial/modules.html#more-on-modules
However, when I attempt to import my own module quadform.py in a separate code by calling
import quadform
quadform.quad_form(1,1,-6)
I get the error:
Traceback (most recent call last):
File "<module1>", line 1, in <module>
ModuleNotFoundError: No module named 'quadform'
Even more confusing is that when I copy + paste the exact code into a separate module saved in the same location, the import on the second module does works. Since then, I have tried various permutations of syntax, using different IDEs, calling from different modules, calling from the shell, and fiddling with the Path in Environment Variables with only a few successes and seemingly at random.
Can someone explain what might be the issue? At the moment, I cannot reliably call any of my modules without getting the same error. I am a beginner trying to pick up Python (and programming in general) on my own so any help would be greatly appreciated.
Read further down:
https://docs.python.org/3.7/tutorial/modules.html#the-module-search-path
https://docs.python.org/3.7/tutorial/modules.html#packages
https://docs.python.org/3.7/tutorial/modules.html#intra-package-references
If you structure your modules like it says, you should be able to import the right things. sys.path is a list of the folders Python looks in to find packages.

panda3d python import error

I have been searching the web for hours now, found several instances where someone had the same problem, but I seem to be too much of a newb with linux/ubuntu to follow the instructions properly, as none of the given solutions worked.
Whenever I try to run a panda3d sample file from the python shell, I would give me an error saying:
Traceback (most recent call last):
File "/usr/share/panda3d/samples/asteroids/main.py", line 16, in
from direct.showbase.ShowBase import ShowBase
ImportError: No module named 'direct'
What really bugs me is that when I try to execute the .py file directly (without opening it in the IDLE or pycharm) it works just fine.
I know this has been asked before, but I would like to ask for a working step by step solution to be able to import panda3d from pycharm and the IDLE. I have no clue how to get it working, as none of the answers given to this question worked for me.
try to change your PYTHONPATH?
i met a problem like this, and then i modify my PYTHONPATH, and it worked.

Python - How do you import downloaded directories/modules?

This is the first time I have attempted to use anything other than what's provided by python.
I have recently gotten into pythons provided Tkinter, though due to some issues I decided to use another GUI, and heard that PyQt was highly recommended, so I downloaded that and looked into various tutorials. In these tutorials, I cannot seem to execute any of the import statements in said tutorials that relate to PyQt, primarily PyQt5 (I have checked I have the correct version number by the way).
So for instance:
import PyQt5
raises the error:
Traceback (most recent call last):
File "/Users/MEBO/PycharmProjects/Music/testing.py", line 1, in <module>
import Qt
ImportError: No module named 'Qt'
[Finished in 0.1s with exit code 1]
I have a lot of research into this. I've heard people talk of using pip to install modules, and I have done this be safe (as well as downloading it from the internet), I've tried changing the project interpreter to versions Python3/ 2.7/ 2.6, appending the path name to the sys.path directory, (which I really know nothing about to be honest, I was hoping I'd get lucky), though nothing seems to work.
Are you supposed to be able to just import a module off the bat, or do you have to set some things up first?
For windows download the package and extract it to (path where python installed)\Python27\Lib and then try to import.
Specific to PyQt
This package cannot just be downloaded and imported, it must be built because it is not pure python, it uses Qt (C++) and requires dependancies. Read this tutorial on installation.
There is also a very complete python package distribution, Anaconda, that includes pyqt and much more. Almost all the packages I ever looked at are in there.
In general to pure python code
In other cases, if you place modules/code that has been download into the directory that your python script is run from, you can import off the bat, or you can append/insert any folder to the sys.path.
# importer will search here last
sys.path.append('/path/to/code/')
# importer will search here second, right after script's directory
# this can be useful to override a module temporarily...
sys.path.insert(1,'/path/to/code/')

Trying to include pypoker, poker-eval package in Python

Ok, so I finally got poker-eval and pypoker to install correctly. If I go to the pypoker folder in cygwin, and type python test.py, it runs the program fine. However, if I copy the test.py file over to a netbeans project main file, I get the error ImportError: No module named _pokereval_2_7. The problem is, I am using wxpython, and it won't let me execute my program from cygwin. I am using NetBeans, so my entire project is developed there. If I try to include pypoker-eval, I get this error.
> Traceback (most recent call last):
> File
> "C:\Users\JeremyLaptop\Documents\NetBeansProjects\testing\src\testing.py",
> line 36, in <module>
> from pokereval import PokerEval File
> "C:\Users\JeremyLaptop\Desktop\pypoker-eval-137.0\pokereval.py",
> line 29, in <module>
> _pokereval = __import__('_pokereval_' + sys.version[0] + '_' + sys.version[2])
> ImportError: No module named _pokereval_2_7.
I have been trying to figure out how to get this to work for hours, hopefully one of you guys can help.
FYI: Windows 7, pypoker and pokereval folders are on my desktop. Projects are saved in C:/users/myname/my documents/netbeansprojects.
A quick look at the source code makes it seem that Python 2.7 is not supported by that library. Try using Python 2.6 instead.
An example of a ready made Texas Hold'em 7- and 5-card evaluator can be found here with documentation and further explained here. It goes by the name of "SpecialKEval". All feedback welcome at the e-mail address found therein.
You can typically (~97% of the time) get away with just 6 additions and a couple of bit shifts. The algo uses a generated look up table which occupies about 9MB of RAM and is generated in a near-instant. Cheap. All of this is done inside of 32-bits, and "inlining" the 7-card evaluator is good for evaluating about 50m randomly generated hands per second on my laptop.
This might be a useful alternative to you in your project.
I had a similar problem. It did not install by default into the default location for my python installation. If something similar is going on for you, then it is probably just not in your PYTONPATH. You can get around that by providing one (or adjusting the path in netbeans, not 100% sure how to do this, but it should be a standard operation) or copying the contents of the site package into your project.

Categories

Resources